100 using std::remove_reference;
106 template<
typename X,
typename TYPES>
109 ,typename TYPES::List
113 template<
typename X,
typename TYPES>
120 template<
typename X,
typename TYPES>
127 template<
typename TYPES,
size_t len>
134 template<
typename X,
typename T,
typename TYPES>
155 template<
class TYPES,
template<
class>
class _P_>
158 static_assert(not
sizeof(TYPES),
"None of the possible Types fulfils the condition");
161 template<
class...TYPES,
template<
class>
class _P_>
166 template<
class T,
class TYPES,
template<
class>
class _P_>
168 : std::conditional_t<_P_<T>::value, Identity<T>, FirstMatchingType<TYPES, _P_>>
173 template<
typename RET>
180 virtual RET
handle(VAL&) {
return RET(); };
185 template<
typename TYPES>
214 template<
typename TYPES>
223 template<
typename RET>
225 template<
typename RET>
258 template<
template<
class>
class _P_>
278 virtual operator string()
const =0;
283 template<
typename TY>
287 static_assert (
SIZ >=
sizeof(TY),
"Variant record: insufficient embedded Buffer size");
292 return * std::launder (
reinterpret_cast<TY*
> (unConst(
this)->ptr()));
323 *
this =
buff.access();
329 *
this = move (rref.access());
343 this->
access() = move(rob);
368 Dispatcher& typeDispatcher = visitor;
369 typeDispatcher.handle (this->
access());
377 Dispatcher& typeDispatcher = visitor;
378 return typeDispatcher.handle (this->
access());
386 Dispatcher& typeDispatcher = visitor;
387 return typeDispatcher.handle (this->
access());
391 operator string()
const;
415 return * std::launder (
reinterpret_cast<const Buffer*
> (&
storage_));
446 using DefaultType = TYPES::List::Head;
480 using RawType = std::remove_reference<X>::type;
482 "Type error: the given variant could never hold the required type");
483 static_assert (std::is_copy_assignable<RawType>::value,
"target type does not support assignment");
485 buff<RawType>() = forward<X>(x);
514 operator string()
const;
524 "Type error: the given variant could never hold the required type");
526 return buff<X>().access();
533 return unConst(
this)->template get<X>();
560 template<
typename TYPES>
563 return "Variant|" + string(buffer());
566 template<
typename TYPES>
567 template<
typename TY>
581 template<
typename TYPES>
582 template<
typename TY>
587 return "Variant type mismatch: expected value of type «"
589 +
"however the given variant record is "
virtual ~Predicate()
this is an interface
virtual ~Renderer()
this is an interface
to be implemented by the client for visitation
virtual ~Visitor()
this is an interface
char storage_[BUFFSIZE]
embedded buffer actually holding the concrete Buff object, which in turn holds and manages the target...
Variant(Variant const &ref)
variant::VFunc< RET >::template VisitorInterface< TYPES > VisitorFunc
bool accept(Predicate &visitor) const
Buffer const & buffer() const
void accept(Visitor &visitor)
string accept(Renderer &visitor) const
variant::VFunc< RET >::template VisitorInterface< meta::ConstAll< typename TYPES::List > > VisitorConstFunc
Lumiera error handling (C++ interface).
Helpers for working with lib::meta::Types (i.e.
meta::InstantiateForEach< typename TYPES::List, ValueAcceptInterface > VisitorInterface
build a generic visitor interface for all types in list
Helper to pick the first type from a type sequence, which fulfils the predicate (meta function) given...
Implementation namespace for support and library code.
LumieraError< LERR_(LOGIC)> Logic
std::string typedString(TY const &val) noexcept
indicate type and possibly a (custom) conversion to string
OBJ * unConst(const OBJ *)
shortcut to save some typing when having to define const and non-const variants of member functions
concrete inner capsule specialised for a given type
bool dispatch(Predicate &visitor) const
void dispatch(Visitor &visitor)
string dispatch(Renderer &visitor) const
void operator=(Buff const &buff)
TY & access() const
< core operation: target is contained within the inline buffer
static string indicateTypeMismatch(Buffer &)
error message when accessing the variant content with wrong type assumptions.
static Buff & downcast(Buffer &b)
Inner capsule managing the contained object (interface)
virtual bool dispatch(Predicate &) const =0
virtual void dispatch(Visitor &)=0
virtual string dispatch(Renderer &) const =0
virtual ~Buffer()
this is an ABC with VTable
how to treat one single type in visitation
virtual RET handle(VAL &)
Metaprogramming: simple helpers for working with lists-of-types.
A template metaprogramming technique for manipulating collections of types.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Helper for building »virtual copy« operations.