AnySet Documentation
|
This class is an implementation detail and is not part of the public interface of AnyValue.
AnyValueLink 'links' the AnyValue instance with its contained object by inheriting from ConstValueHolder<Value>. ConstValueHolder conditionally inherits from 'Value', depending on whether 'Value' is a non-final class type. The inheritence heirarchy looks like this:
AnyValue Value ^ ^ \ / <<< This part of the inheritence tree is conditional TypedValue ConstValueHolder ^ ^ \ / AnyValueLink (final)
This allows us to implement polymorphic_cast() with a simple dynamic_cast. Since AnyValue introduces RTTI into the heirarchy, polymorphic_cast() can cast through Value's
public inheritance heirarchy without knowing what the actual type of Value is, in spite of the fact that Value may not even be a polymorphic type itself.
#include <AnyNode.h>
Public Types | |
using | self_type = AnyValueLink< Value, HashFn, Compare > |
using | holder_type = ConstValueHolder< Value > |
using | base_type = TypedValue< Value, HashFn, Compare > |
![]() | |
using | base_type = AnyValue< HashFn, Compare > |
using | value_type = Value |
using | holder_type = ConstValueHolder< value_type > |
using | self_type = TypedValue< Value, HashFn, Compare > |
using | link_type = AnyValueLink< Value, HashFn, Compare > |
![]() | |
using | self_type = AnyValue< HashFn, Compare > |
using | hasher = HashFn |
using | key_equal = Compare |
Public Member Functions | |
template<class ... Args> | |
AnyValueLink (std::size_t hash_v, Args &&... args) | |
template<class ... Args> | |
AnyValueLink (HashFn hasher, Args &&... args) | |
![]() | |
TypedValue (const self_type &)=delete | |
TypedValue (self_type &&)=delete | |
self_type & | operator= (const self_type &)=delete |
self_type & | operator= (self_type &&)=delete |
bool | equals (const base_type &other) const final override |
bool | not_equals (const base_type &other) const final override |
bool | compare_to (const base_type &other, Compare comp) const final override |
void | write (std::ostream &os) const final override |
std::unique_ptr< base_type > | clone () const final override |
const std::type_info & | typeinfo () const final override |
Get a reference to a std::type_info object that indicates the type of the contained object. More... | |
const value_type & | value () const & |
const value_type && | value () const && |
![]() | |
AnyValue (const AnyValue &)=delete | |
AnyValue (AnyValue &&)=delete | |
Friends | |
struct | TypedValue< Value, HashFn, Compare > |
const Value & | get_value (const self_type &self) |
const Value && | get_value (const self_type &&self) |
Additional Inherited Members | |
![]() | |
const std::size_t | hash |
The hash code obtained by invoking an instance of HashFn on the contained object. More... | |
![]() | |
TypedValue (std::size_t hash_v) | |
![]() | |
AnyValue (std::size_t hash_v) | |
![]() | |
template<class T , class H , class C > | |
bool | is (const AnyValue< H, C > &any_v) |
Check if any_v contains an object of type T. More... | |
template<class T , class H , class C , class ... Args> | |
std::unique_ptr< AnyValue< H, C > > | make_any_value (std::size_t hash_value, Args &&... args) |
Constructs a std::unique_ptr<AnyValue<H, C>> suitable for splicing into an AnySet instance. More... | |
template<class T , class H , class C , class ... Args> | |
std::unique_ptr< AnyValue< H, C > > | make_any_value (H hasher, Args &&... args) |
Constructs a std::unique_ptr<AnyValue<H, C>> suitable for splicing into an AnySet< C> instance. More... | |
template<class To , class H , class C > | |
To | polymorphic_cast (const AnyValue< H, C > &any_v) |
Access the contained object through a reference to dynamic type To . More... | |
template<class To , class H , class C > | |
To | polymorphic_cast (const AnyValue< H, C > *any_v) |
Access the contained object through a pointer to dynamic type To . More... | |
template<class To , class H , class C > | |
To | exact_cast (const AnyValue< H, C > &any_v) |
Access the contained object. More... | |
template<class To , class H , class C > | |
To | exact_cast (const AnyValue< H, C > *any_v) |
Access the contained object. More... | |
template<class To , class H , class C > | |
To | unsafe_cast (const AnyValue< H, C > &any_v) |
Access the contained object without dynamic type checking. More... | |
template<class T , class H , class C > | |
const T * | try_as (const AnyValue< H, C > &any_v) |
Get a pointer to the contained object of type T. If the contained object is not an instance of type T, returns nullptr. More... | |
template<class T , class H , class C > | |
const T & | as (const AnyValue< H, C > &self) |
Get a reference to the contained object of type T. If the contained object is not an instance of type T, throws a std::bad_cast. More... | |
template<class T , class H , class C > | |
const T & | get (const AnyValue< H, C > &any_v) |
template<class T , class H , class C , class DefaultRef > | |
const std::decay_t< T > & | get_default_ref (const AnyValue< H, C > &any_v, DefaultRef &&default_ref) |
Get the contained value in any_v through a reference to const T . More... | |
template<class T , class H , class C , class DefaultVal > | |
T | get_default_val (const AnyValue< H, C > &any_v, DefaultVal &&default_val) |
Get a copy of the contained value in any_v of type T . More... | |