152#ifndef LIB_POLYMORPHIC_VALUE_H
153#define LIB_POLYMORPHIC_VALUE_H
166 namespace polyvalue {
230 enum{
value = HasFunName_cloneInto<T>::value
245 and not HasMember_copyInto<T>::value
254 template<
class API,
class YES =
void>
279 throw error::Logic(
"attempt to overwrite unmodifiable value");
293 template <
class TY,
class YES =
void>
305 return dynamic_cast<CopyAPI&
> (bufferContents);
330 return static_cast<CopyAPI&
> (bufferContents);
386 return * std::launder (
reinterpret_cast<IFA*
> (&
buf_));
414 new(targetBuffer)
Adapter(*
this);
422 _AssignmentPolicy::assignEmbedded(target,*
this);
427 template<
typename...ARGS>
429 : IMP(
std::forward<ARGS>(args)...)
435 template<
typename IMP>
450 template<
class IMP,
typename...ARGS>
453 static_assert (
siz >=
sizeof(
Adapter<IMP>),
"insufficient inline buffer size");
466 template<
class IMP,
typename...ARGS>
515 template<
class IMP,
typename...ARGS>
520 return PolymorphicValue (type_to_build_in_buffer, std::forward<ARGS>(args)...);
534 return not (v1 == v2);
Implementation Helper: add support for copy operations.
virtual void cloneInto(void *targetBuffer) const
virtual void copyInto(IFA &targetBase) const
Template to build polymorphic value objects.
PolymorphicValue(TypeSelector< IMP >, ARGS &&... args)
Adapter< IMP > * TypeSelector
PolymorphicValue(PolymorphicValue const &o)
_Traits::Assignment _AssignmentPolicy
IFA & accessEmbedded() const
_CopyHandlingAdapter & accessHandlingInterface() const
polyvalue::Trait< CPY > _Traits
Interface * operator->() const
static PolymorphicValue build(ARGS &&... args)
friend bool operator!=(PolymorphicValue const &v1, PolymorphicValue const &v2)
PolymorphicValue(IMP *, ARGS &&... args)
friend bool operator==(PolymorphicValue const &v1, PolymorphicValue const &v2)
std::byte buf_[siz]
Storage for embedded objects.
_Traits::CopyAPI _CopyHandlingAdapter
PolymorphicValue & operator=(PolymorphicValue const &o)
A variation for limited copy support.
virtual ~CloneValueSupport()
virtual void cloneInto(void *targetBuffer) const =0
Interface for active support of copy operations by the embedded client objects.
virtual void cloneInto(void *targetBuffer) const =0
virtual void copyInto(IFA &targetBase) const =0
helper to detect if the API supports only copy construction, but no assignment
META_DETECT_MEMBER(copyInto)
helper to detect presence of a function to support clone operations
META_DETECT_FUNCTION_NAME(cloneInto)
Metaprogramming helpers to check for specific properties of a type in question.
Lumiera error handling (C++ interface).
Implementation namespace for support and library code.
LumieraError< LERR_(LOGIC)> Logic
static void assignEmbedded(IMP &, IMP const &)
Policy class for invoking the assignment operator.
static void assignEmbedded(IMP &dest, IMP const &src)
AssignmentPolicy< CopyAPI > Assignment
struct{ } AdapterAttachment
static CopyAPI & accessCopyHandlingInterface(IFA &bufferContents)
trait template to deal with different ways to support copy operations.
AssignmentPolicy< CopyAPI > Assignment
CopySupport< TY, EmptyBase > CopyAPI
static CopyAPI & accessCopyHandlingInterface(TY &bufferContents)
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
#define INSTANCEOF(CLASS, EXPR)
shortcut for subclass test, intended for assertions only.