|
variant.hpp
Go to the documentation of this file.
11 /*************************************************************************************************/
91 static const std::size_t MAX_SIZE = mpl::fold<Types, mpl::size_t<0>, mpl::max<mpl::_1, mpl::sizeof_<mpl::_2> > >::type::value;
96 typedef struct { char data[MAX_SIZE]; } base_t; // empty space equal to the size of the largest type in Types
103 template <typename T> explicit variant(const T& obj){ _index=type_id<T>(); if (_index==NUM_TYPES) throw std::bad_cast(); detail::copy_construct_in_place(obj, _bits); }
105 template <typename Types2> explicit variant(const variant<Types2>& obj) : _index(apply_operation(obj,detail::type_to_index_fn<Types>())) {
110 // When doSwap is true, swaps obj with the contents of the variant. obj will contain default-constructed instance after the call
113 template <typename T> variant& operator=(const T& obj) { variant tmp(obj); swap(*this,tmp); return *this; }
116 variant(const variant& v) : _index(v._index) { apply_operation(v, detail::copy_construct_in_place_fn<base_t>(_bits)); }
124 template <typename T> const T& _dynamic_cast() const { if (!current_type_is<T>()) throw std::bad_cast(); return *gil_reinterpret_cast_c<const T*>(&_bits); }
125 template <typename T> T& _dynamic_cast() { if (!current_type_is<T>()) throw std::bad_cast(); return *gil_reinterpret_cast < T*>(&_bits); }
133 template <typename T> static std::size_t type_id() { return detail::type_to_index<Types,T>::value; }
136 template <typename Types2, typename UnaryOp> friend typename UnaryOp::result_type apply_operation(variant<Types2>& var, UnaryOp op);
137 template <typename Types2, typename UnaryOp> friend typename UnaryOp::result_type apply_operation(const variant<Types2>& var, UnaryOp op);
138 template <typename Types1, typename Types2, typename BinaryOp> friend typename BinaryOp::result_type apply_operation(const variant<Types1>& arg1, const variant<Types2>& arg2, BinaryOp op);
158 template <typename T> void operator()(const T& src) const { copy_construct_in_place(src,_dst); }
176 template <typename T> result_type operator()(const T&) const { return detail::type_to_index<Types,T>::value; }
180 // When doSwap is true, swaps obj with the contents of the variant. obj will contain default-constructed instance after the call
201 return x._index==y._index && apply_operation(x,detail::equal_to_fn<typename variant<Types>::base_t>(y._bits));
BOOST_FORCEINLINE UnaryOp::result_type apply_operation(variant< Types > &arg, UnaryOp op) Invokes a generic mutable operation (represented as a unary function object) on a variant... Definition: apply_operation.hpp:35 Represents a concrete instance of a run-time specified type from a set of typesA concept is typically... Definition: variant.hpp:89 void swap(const boost::gil::planar_pixel_reference< CR, CS > x, const boost::gil::planar_pixel_reference< CR, CS > y) swap for planar_pixel_reference Definition: planar_pixel_reference.hpp:193 Returns the index corresponding to the first occurrance of a given given type in. ... Definition: utilities.hpp:296 Generated on Mon Mar 26 2018 16:26:16 for Generic Image Library by
1.8.6
|