KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ki Namespace Reference

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

Classes

class  any
 A type-safe container of any type. More...
 
class  bad_any_cast
 Exception class thrown by a failed any_cast. More...
 

Functions

void 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... >, anymake_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... >, anymake_any (std::initializer_list< U > il, Args &&... args)
 Create an any holding a T constructed from il and args....
 
template<typename ValueType >
ValueType any_cast (const any &any)
 Access the contained object.
 
template<typename ValueType >
ValueType any_cast (any &any)
 Access the contained object.
 
template<typename ValueType >
ValueType any_cast (any &&any)
 
template<typename ValueType >
const ValueType * any_cast (const any *any) noexcept
 Access the contained object.
 
template<typename ValueType >
ValueType * any_cast (any *any) noexcept
 

Variables

template<typename >
constexpr bool 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.

Function Documentation

◆ any_cast() [1/5]

template<typename ValueType >
ValueType ki::any_cast ( any &&  any)

Definition at line 489 of file ki_any.h.

References any_cast().

◆ any_cast() [2/5]

template<typename ValueType >
ValueType ki::any_cast ( any any)

Access the contained object.

Template Parameters
ValueTypeA reference or CopyConstructible type.
Parameters
anyThe object to access.
Returns
The contained object.
Exceptions
bad_any_castIf any.type() != typeid(remove_reference_t<ValueType>)

Definition at line 471 of file ki_any.h.

References any_cast().

◆ any_cast() [3/5]

template<typename ValueType >
ValueType * ki::any_cast ( any any)
noexcept

Definition at line 565 of file ki_any.h.

References any_cast().

◆ any_cast() [4/5]

template<typename ValueType >
ValueType ki::any_cast ( const any any)

Access the contained object.

Template Parameters
ValueTypeA const-reference or CopyConstructible type.
Parameters
anyThe object to access.
Returns
The contained object.
Exceptions
bad_any_castIf any.type() != typeid(remove_reference_t<ValueType>)

Definition at line 442 of file ki_any.h.

References any_cast().

Referenced by any_cast().

◆ any_cast() [5/5]

template<typename ValueType >
const ValueType * ki::any_cast ( const any any)
noexcept

Access the contained object.

Template Parameters
ValueTypeThe type of the contained object.
Parameters
anyA pointer to the object to access.
Returns
The address of the contained object if any != nullptr && any.type() == typeid(ValueType) , otherwise a null pointer.

Definition at line 549 of file ki_any.h.

References any_cast().

◆ make_any() [1/2]

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...

Definition at line 416 of file ki_any.h.

◆ make_any() [2/2]

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....

Definition at line 426 of file ki_any.h.

◆ swap()

void ki::swap ( any x,
any y 
)
inlinenoexcept

Exchange the states of two any objects.

Definition at line 408 of file ki_any.h.

Variable Documentation

◆ is_in_place_type_v

template<typename >
constexpr bool ki::is_in_place_type_v< std::in_place_type_t< T > > = false
inlineconstexpr

Definition at line 68 of file ki_any.h.