Lumiera  0.pre.03
»edit your freedom«
access-casted-o.hpp File Reference

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>

Classes

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

Namespaces