KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ki_any.h File Reference

An implementation of std::any_cast, which uses type_info::hash_code to check validity of cast types. More...

#include <initializer_list>
#include <new>
#include <typeinfo>
#include <utility>

Go to the source code of this file.

Classes

class  ki::bad_any_cast
 Exception class thrown by a failed any_cast. More...
 
class  ki::any
 A type-safe container of any type. More...
 
union  ki::any::Storage
 
union  ki::any::Arg
 
struct  ki::any::Manager_Internal< T >
 
struct  ki::any::Manager_External< T >
 

Namespaces

namespace  ki
 

Functions

void ki::swap (any &x, any &y) noexcept
 Exchange the states of two any objects.
 
template<typename T , typename... Args>
std::enable_if_t< std::is_constructible_v< any, std::in_place_type_t< T >, Args... >, any > ki::make_any (Args &&... args)
 Create a any holding a T constructed from args....
 
template<typename T , typename U , typename... Args>
std::enable_if_t< std::is_constructible_v< any, std::in_place_type_t< T >, std::initializer_list< U > &, Args... >, any > ki::make_any (std::initializer_list< U > il, Args &&... args)
 Create an any holding a T constructed from il and args....
 
template<typename ValueType >
ValueType ki::any_cast (const any &any)
 Access the contained object.
 
template<typename ValueType >
ValueType ki::any_cast (any &any)
 Access the contained object.
 
template<typename ValueType >
ValueType ki::any_cast (any &&any)
 
template<typename ValueType >
const ValueType * ki::any_cast (const any *any) noexcept
 Access the contained object.
 
template<typename ValueType >
ValueType * ki::any_cast (any *any) noexcept
 

Variables

template<typename >
constexpr bool ki::is_in_place_type_v = false
 

Detailed Description

An implementation of std::any_cast, which uses type_info::hash_code to check validity of cast types.

This is required as Clang compares types as being equivalent based on their type_info pointer locations. These are not guaranteed to be the same with identical types linked in multiple targets from shared libraries. The current Clang implementation of type_info::hash_code is based on the type names, which should be consistent across translation units.

Definition in file ki_any.h.