File indexing completed on 2025-07-09 08:28:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_VARIANT_DETAIL_INITIALIZER_HPP
0014 #define BOOST_VARIANT_DETAIL_INITIALIZER_HPP
0015
0016 #include <new> // for placement new
0017
0018 #include <boost/config.hpp>
0019
0020 #include <boost/call_traits.hpp>
0021 #include <boost/detail/reference_content.hpp>
0022 #include <boost/variant/recursive_wrapper_fwd.hpp>
0023 #include <boost/variant/detail/move.hpp>
0024
0025 # include <boost/mpl/aux_/value_wknd.hpp>
0026 # include <boost/mpl/int.hpp>
0027 # include <boost/mpl/iter_fold.hpp>
0028 # include <boost/mpl/next.hpp>
0029 # include <boost/mpl/deref.hpp>
0030 # include <boost/mpl/pair.hpp>
0031 # include <boost/mpl/protect.hpp>
0032
0033
0034 namespace boost {
0035 namespace detail { namespace variant {
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 struct make_initializer_node
0055 {
0056 template <typename BaseIndexPair, typename Iterator>
0057 struct apply
0058 {
0059 private:
0060
0061 typedef typename BaseIndexPair::first
0062 base;
0063 typedef typename BaseIndexPair::second
0064 index;
0065
0066 class initializer_node
0067 : public base
0068 {
0069 private:
0070
0071 typedef typename mpl::deref<Iterator>::type
0072 recursive_enabled_T;
0073 typedef typename unwrap_recursive<recursive_enabled_T>::type
0074 public_T;
0075
0076 typedef boost::is_reference<public_T>
0077 is_reference_content_t;
0078
0079 typedef typename boost::mpl::if_<is_reference_content_t, public_T, const public_T& >::type
0080 param_T;
0081
0082 template <class T> struct disable_overload{};
0083
0084 typedef typename boost::mpl::if_<is_reference_content_t, disable_overload<public_T>, public_T&& >::type
0085 param2_T;
0086
0087 public:
0088
0089 using base::initialize;
0090
0091 static int initialize(void* dest, param_T operand)
0092 {
0093 typedef typename boost::detail::make_reference_content<
0094 recursive_enabled_T
0095 >::type internal_T;
0096
0097 new(dest) internal_T(operand);
0098 return BOOST_MPL_AUX_VALUE_WKND(index)::value;
0099 }
0100
0101 static int initialize(void* dest, param2_T operand)
0102 {
0103
0104
0105 BOOST_ASSERT(!is_reference_content_t::value);
0106
0107 typedef typename boost::mpl::if_<is_reference_content_t, param2_T, recursive_enabled_T>::type value_T;
0108 new(dest) value_T( boost::detail::variant::move(operand) );
0109 return BOOST_MPL_AUX_VALUE_WKND(index)::value;
0110 }
0111 };
0112
0113 friend class initializer_node;
0114
0115 public:
0116
0117 typedef mpl::pair<
0118 initializer_node
0119 , typename mpl::next< index >::type
0120 > type;
0121
0122 };
0123 };
0124
0125
0126
0127
0128
0129
0130 class initializer_root
0131 {
0132 public:
0133
0134 static void initialize();
0135
0136 };
0137
0138 }}
0139 }
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149 #define BOOST_VARIANT_AUX_INITIALIZER_T( mpl_seq, typename_base ) \
0150 ::boost::mpl::iter_fold< \
0151 mpl_seq \
0152 , ::boost::mpl::pair< \
0153 ::boost::detail::variant::initializer_root \
0154 , ::boost::mpl::int_<0> \
0155 > \
0156 , ::boost::mpl::protect< \
0157 ::boost::detail::variant::make_initializer_node \
0158 > \
0159 >::type::first \
0160
0161
0162 #endif