Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
access-casted-o.hpp File Reference

Helper for accessing a value, employing either conversion or downcast, depending on the relation of the source type (type of the original value) and the target type (type we need within the usage context). More...

Go to the source code of this file.

Description

Helper for accessing a value, employing either conversion or downcast, depending on the relation of the source type (type of the original value) and the target type (type we need within the usage context).

When instantiating AcessCasted<TAR>, we get a template static function AcessCasted<TAR>::access<SRC>(SRC& elm), but the actual implementation is chosen using std::type_traits. If no sensible implementation can be selected, EmptyVal<TAR>::create() is invoked instead, which by default creates a NULL value or similar by using the no-argument ctor of the type TAR. Alternatively, you may define an specialisation of EmptyVal, e.g. throwing an exception instead of creating a NULL value.

Deprecated:
old obsolete version ///////////////////////////////////////////TICKET #738 clean-up access-casted, rewrite variant (4/2015)
Todo:
This is the obsoleted old version: It was excessively permissive, which I've learned to view as a danger, since it encourages a sloppy programming style.
See also
lumiera::WrapperPtr usage example to access a variant record
lib::InPlaceAnyHolder usage example to access a subclass in embedded storage

Definition in file access-casted-o.hpp.

#include <type_traits>

Namespaces

namespace  util
 
namespace  util::anonymous_namespace{access-casted-o.hpp}
 

Classes

struct  can_cast< SRC, TAR >
 
struct  can_cast< SRC *, TAR * >
 
struct  can_cast< SRC *&, TAR * >
 
struct  can_cast< SRC &, TAR & >
 
struct  hasRTTI< T >
 
struct  use_dynamic_downcast< SRC, TAR >
 
struct  use_static_downcast< SRC, TAR >
 
struct  use_conversion< SRC, TAR >
 
struct  EmptyVal< X >
 
struct  EmptyVal< X *& >
 
struct  NullAccessor< RET >
 
struct  AccessCasted_O< TAR >