ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
ScriptInterface::impl::recursive_variant< Ts > Struct Template Reference

Recursive variant implementation. More...

#include <Variant.hpp>

+ Inheritance diagram for ScriptInterface::impl::recursive_variant< Ts >:
+ Collaboration diagram for ScriptInterface::impl::recursive_variant< Ts >:

Public Types

using BaseClass = recursive_variant_add_containers< Ts... >
 
template<class T >
using has_type = std::disjunction< std::is_same< T, Ts >... >
 Is a given type part of this variant's type list.
 

Friends

class boost::serialization::access
 

Detailed Description

template<class... Ts>
struct ScriptInterface::impl::recursive_variant< Ts >

Recursive variant implementation.

This boilerplate code is required to emulate the following Boost feature:

using Variant = boost::make_recursive_variant<
int, double, std::string, std::vector<boost::recursive_variant_>,
std::unordered_map<std::string, boost::recursive_variant_>>::type;
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
Recursive variant implementation.
Definition Variant.hpp:84

C++ doesn't natively supports the kind of reflections needed to implement this behavior. Our implementation splits the definition in two classes: a forward-declared recursive_variant template class whose type parameters are "basic" types (i.e. non-recursive types), and a helper class recursive_variant_add_containers that injects carefully chosen STL containers into the type list. Since STL containers store a pointer to a buffer holding variant instances, the variant size doesn't need to be known at the time the variant is defined, and the variant is recursive.

Definition at line 84 of file Variant.hpp.

Member Typedef Documentation

◆ BaseClass

Definition at line 85 of file Variant.hpp.

◆ has_type

template<class... Ts>
template<class T >
using ScriptInterface::impl::recursive_variant< Ts >::has_type = std::disjunction<std::is_same<T, Ts>...>

Is a given type part of this variant's type list.

Definition at line 89 of file Variant.hpp.

Friends And Related Symbol Documentation

◆ boost::serialization::access

template<class... Ts>
friend class boost::serialization::access
friend

Definition at line 92 of file Variant.hpp.


The documentation for this struct was generated from the following file: