BitShares-Core
7.0.2
BitShares blockchain node software and command-line wallet software
|
Go to the documentation of this file.
36 void alloc(
size_t size );
43 template<
typename... Types>
51 "Reference types are not permitted in static_variant.");
53 "static_variant type arguments contain duplicate types.");
61 template<
typename X,
typename = type_in_typelist<X>>
63 _tag = typelist::index_of<list, X>();
68 template<
typename X,
typename = type_in_typelist<X>>
70 _tag = typelist::index_of<list, X>();
77 FC_ASSERT( tag >= 0,
"Unable to init with a negative tag '${tag}'", (
"tag",tag) );
79 "Unable to init with tag '${tag}' when the number of supported tags is ${count}",
80 (
"tag",tag) (
"count",
count()) );
83 using T =
typename decltype(t)::type;
92 using T = typename decltype(t)::type;
93 reinterpret_cast<T*>(data)->~T();
98 template<
typename T,
typename =
void>
101 FC_THROW_EXCEPTION(assert_exception,
"Cannot import unsupported type ${T} into static_variant",
105 FC_THROW_EXCEPTION(assert_exception,
"Cannot import unsupported type ${T} into static_variant",
120 template<
typename X,
typename = type_in_typelist<X>>
136 template<
typename... Other>
139 using other_type = typename decltype(t)::type;
140 return import_helper<other_type>::construct(other.template get<other_type>());
145 template<
typename... Other>
148 using other_type = typename decltype(t)::type;
149 return import_helper<other_type>::construct(std::move(other.template get<other_type>()));
158 template<
typename... Other>
162 this->init(cpy.template get<typename decltype(t)::type>());
169 this->init(cpy.template get<typename decltype(t)::type>());
176 this->init(std::move(mv.template get<typename decltype(t)::type>()));
180 template<
typename... Other>
184 this->init(std::move(mv.template get<typename decltype(t)::type>()));
188 template<
typename X,
typename = type_in_typelist<X>>
192 template<
typename X,
typename = type_in_typelist<X>>
201 template<
typename X,
typename = type_in_typelist<X>>
209 if(
this == &v )
return *
this;
212 this->init(v.template get<typename decltype(t)::type>());
218 if(
this == &v )
return *
this;
221 this->init(std::move(v.template get<typename decltype(t)::type>()));
230 using Value = typename decltype(t)::type;
231 return a.template get<Value>() == b.template get<Value>();
235 template<
typename X,
typename = type_in_typelist<X>>
237 if(
_tag == typelist::index_of<list, X>()) {
241 "static_variant does not contain a value of type ${t}",
245 template<
typename X,
typename = type_in_typelist<X>>
247 if(
_tag == typelist::index_of<list, X>()) {
248 return *
reinterpret_cast<const X*
>(
storage.
data());
251 "static_variant does not contain a value of type ${t}",
255 template<
typename visitor>
260 template<
typename visitor>
265 template<
typename visitor>
270 template<
typename visitor>
275 template<
typename visitor>
279 "Unsupported type '${tag}', the number of supported types is ${count}! ",
280 (
"tag",tag) (
"count",
count()) );
282 return v(*
reinterpret_cast<typename decltype(t)::type*
>(data));
286 template<
typename visitor>
290 "Unsupported type '${tag}', the number of supported types is ${count}! ",
291 (
"tag",tag) (
"count",
count()) );
293 return v(*
reinterpret_cast<typename decltype(t)::type*
>(data));
297 template<
typename visitor>
301 "Unsupported type '${tag}', the number of supported types is ${count}! ",
302 (
"tag",tag) (
"count",
count()) );
304 return v(*
reinterpret_cast<const typename decltype(t)::type*
>(data));
308 template<
typename visitor>
312 "Unsupported type '${tag}', the number of supported types is ${count}! ",
313 (
"tag",tag) (
"count",
count()) );
315 return v(*
reinterpret_cast<const typename decltype(t)::type*
>(data));
319 static constexpr
size_t count() {
return typelist::length<list>(); }
321 FC_ASSERT( tag >= 0,
"Unable to set a negative tag '${tag}'", (
"tag",tag) );
323 "Unable to set tag '${tag}' when the number of supported tags is ${count}",
324 (
"tag",tag) (
"count",
count()) );
380 if( ar.size() < 2 )
return;
390 static const char*
names() {
return ""; }
393 template<
typename T >
403 template<
typename T,
typename... Ts >
408 static const std::string n =
415 template<
typename... T >
420 static const std::string n = std::string(
"fc::static_variant<" )
static const char * names()
static static_variant import_from(const static_variant< Other... > &other)
static const char * names()
typename impl::concat_unique< list<>, TypeLists... >::type concat_unique
Remove duplicate items from one or more typelists and concatenate them all together.
static_variant & operator=(const static_variant &v)
const uint32_t _max_depth
static visitor::result_type visit(tag_type tag, const visitor &v, void *data)
static_variant & operator=(const X &v)
typelist::list< Types... > list
static static_variant construct(T &&t)
static constexpr size_t count()
static_variant(const static_variant &cpy)
static static_variant construct(const T &)
object_restriction_predicate< operation > result_type
visitor::result_type visit(const visitor &v) const
visitor::result_type visit(const visitor &v)
void from_variant(const variant &var, flat_set< T, A... > &vo, uint32_t _max_depth)
static_variant(static_variant &&mv)
bool operator()(const static_variant &a, const static_variant &b) const
This namespace contains the list type, and all of the operations and queries which can be performed u...
static constexpr tag_type value
std::vector< variant > variants
static static_variant construct(T &&)
static const char * name()
static visitor::result_type visit(tag_type tag, const visitor &v, const void *data)
from_static_variant(variant &dv, uint32_t max_depth)
static static_variant import_from(static_variant< Other... > &&other)
const uint32_t _max_depth
void to_variant(const flat_set< T, A... > &var, variant &vo, uint32_t _max_depth)
static_variant & operator=(static_variant &&v)
friend bool operator==(const static_variant &a, const static_variant &b)
static const char * names()
void init_from_tag(tag_type tag)
static static_variant construct(const T &t)
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
void operator()(const T &v) const
static_variant(static_variant< Other... > &&mv)
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
visitor::result_type visit(visitor &v) const
Defines exception's used by fc.
to_static_variant(const variant &dv, uint32_t max_depth)
static_variant(const X &v)
static visitor::result_type visit(tag_type tag, visitor &v, void *data)
std::enable_if_t< typelist::index_of< list, X >() !=-1 > type_in_typelist
void set_which(tag_type tag)
visitor::result_type visit(visitor &v)
static_variant(const static_variant< Other... > &cpy)
Return dispatch(list< Types... >, std::size_t index, Callable c)
Index into the typelist for a type T, and invoke the callable with an argument wrapper<T>()
flat_set< static_variant, type_lt > flat_set_type
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
impl::dynamic_storage storage
typename impl::filter< Filter, list<>, List >::type filter
Get a list with all elements that do not pass a filter removed.
void operator()(T &v) const
static visitor::result_type visit(tag_type tag, visitor &v, const void *data)
bool operator()(const static_variant &a, const static_variant &b) const