KiCad PCB EDA Suite
|
A type-safe container of any type. More...
#include <ki_any.h>
Classes | |
union | Arg |
struct | Manager_External |
struct | Manager_Internal |
union | Storage |
Public Member Functions | |
constexpr | any () noexcept |
Default constructor, creates an empty object. | |
any (const any &other) | |
Copy constructor, copies the state of other . | |
any (any &&other) noexcept | |
Move constructor, transfer the state from other . | |
template<typename T , typename V = decay_if_not_any<T>, typename Mgr = Manager<V>, std::enable_if_t< std::is_copy_constructible_v< V > &&!is_in_place_type_v< V >, bool > = true> | |
any (T &&value) | |
Construct with a copy of value as the contained object. | |
template<typename T , typename... Args, typename V = std::decay_t<T>, typename Mgr = Manager<V>, any_constructible_t< V, Args &&... > = false> | |
any (std::in_place_type_t< T >, Args &&... args) | |
Construct with an object created from args as the contained object. | |
template<typename T , typename U , typename... Args, typename V = std::decay_t<T>, typename Mgr = Manager<V>, any_constructible_t< V, std::initializer_list< U > &, Args &&... > = false> | |
any (std::in_place_type_t< T >, std::initializer_list< U > il, Args &&... args) | |
Construct with an object created from il and args as the contained object. | |
~any () | |
Destructor, calls reset() . | |
any & | operator= (const any &rhs) |
Copy the state of another object. | |
any & | operator= (any &&rhs) noexcept |
Move assignment operator. | |
template<typename T > | |
std::enable_if_t< std::is_copy_constructible_v< decay_if_not_any< T > >, any & > | operator= (T &&rhs) |
Store a copy of rhs as the contained object. | |
template<typename T , typename... Args> | |
any_emplace_t< std::decay_t< T >, Args... > | emplace (Args &&... args) |
Emplace with an object created from args as the contained object. | |
template<typename T , typename U , typename... Args> | |
any_emplace_t< std::decay_t< T >, std::initializer_list< U > &, Args &&... > | emplace (std::initializer_list< U > il, Args &&... args) |
Emplace with an object created from il and args as the contained object. | |
void | reset () noexcept |
If not empty, destroys the contained object. | |
void | swap (any &rhs) noexcept |
Exchange state with another object. | |
bool | has_value () const noexcept |
Report whether there is a contained object or not. | |
const std::type_info & | type () const noexcept |
The typeid of the contained object, or typeid(void) if empty. | |
Private Types | |
enum | Op { Op_Access , Op_Get_Type_Info , Op_Clone , Op_Destroy , Op_Xfer } |
template<typename T , bool Safe = std::is_nothrow_move_constructible_v<T>, bool Fits = ( sizeof( T ) <= sizeof( Storage ) ) && ( alignof( T ) <= alignof( Storage ) )> | |
using | Use_Internal_Storage = std::integral_constant< bool, Safe &&Fits > |
template<typename T > | |
using | Manager = std::conditional_t< Use_Internal_Storage< T >::value, Manager_Internal< T >, Manager_External< T > > |
template<typename T , typename V = std::decay_t<T>> | |
using | decay_if_not_any = std::enable_if_t<!std::is_same_v< V, any >, V > |
template<typename Res , typename T , typename... Args> | |
using | any_constructible = std::enable_if< std::is_copy_constructible_v< T > &&std::is_constructible_v< T, Args... >, Res > |
template<typename T , typename... Args> | |
using | any_constructible_t = typename any_constructible< bool, T, Args... >::type |
template<typename V , typename... Args> | |
using | any_emplace_t = typename any_constructible< V &, V, Args... >::type |
Private Member Functions | |
template<typename T , typename... Args, typename Mgr = Manager<T>> | |
void | do_emplace (Args &&... args) |
Emplace with an object created from args as the contained object. | |
template<typename T , typename U , typename... Args, typename Mgr = Manager<T>> | |
void | do_emplace (std::initializer_list< U > il, Args &&... args) |
Emplace with an object created from il and args as the contained object. | |
Private Attributes | |
void(* | m_manager )(Op, const any *, Arg *) |
Storage | m_storage |
A type-safe container of any type.
An any
object's state is either empty or it stores a contained object of CopyConstructible type.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
inlineconstexprnoexcept |
Default constructor, creates an empty object.
Definition at line 156 of file ki_any.h.
Referenced by operator=().
|
inline |
Copy constructor, copies the state of other
.
Definition at line 159 of file ki_any.h.
References has_value(), ki::any::Arg::m_any, m_manager, and Op_Clone.
|
inlinenoexcept |
Move constructor, transfer the state from other
.
Definition at line 174 of file ki_any.h.
References ki::any::Arg::m_any, m_manager, and Op_Xfer.
|
inline |
|
inlineexplicit |
|
inlineexplicit |
|
inline |
|
inlineprivate |
|
inlineprivate |
|
inline |
Emplace with an object created from args
as the contained object.
Definition at line 254 of file ki_any.h.
References m_storage.
Referenced by BOOST_AUTO_TEST_CASE().
|
inline |
|
inlinenoexcept |
Report whether there is a contained object or not.
Definition at line 312 of file ki_any.h.
References m_manager.
Referenced by any(), BOOST_AUTO_TEST_CASE(), TOOL_MANAGER::doRunAction(), TOOL_ACTION::GetParam(), TOOL_ACTION::MakeEvent(), TOOL_EVENT::Parameter(), reset(), swap(), TOOL_ACTION::TOOL_ACTION(), and type().
|
inline |
|
inlinenoexcept |
If not empty, destroys the contained object.
Definition at line 272 of file ki_any.h.
References has_value(), m_manager, and Op_Destroy.
Referenced by BOOST_AUTO_TEST_CASE(), do_emplace(), operator=(), and ~any().
|
inlinenoexcept |
Exchange state with another object.
Definition at line 282 of file ki_any.h.
References empty(), has_value(), ki::any::Arg::m_any, m_manager, and Op_Xfer.
Referenced by BOOST_AUTO_TEST_CASE().
|
inlinenoexcept |
The typeid
of the contained object, or typeid(void)
if empty.
Definition at line 316 of file ki_any.h.
References has_value(), m_manager, ki::any::Arg::m_typeinfo, and Op_Get_Type_Info.
Referenced by BOOST_AUTO_TEST_CASE(), TOOL_ACTION::GetParam(), and TOOL_EVENT::Parameter().
Definition at line 351 of file ki_any.h.
Referenced by any(), do_emplace(), has_value(), ki::any::Manager_Internal< T >::m_manage_fn(), ki::any::Manager_External< T >::m_manage_fn(), operator=(), reset(), swap(), and type().
|
private |
Definition at line 352 of file ki_any.h.
Referenced by any(), do_emplace(), emplace(), ki::any::Manager_Internal< T >::m_manage_fn(), and ki::any::Manager_External< T >::m_manage_fn().