Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
1 //-----------------------------------------------------------------------------
2 // boost variant/detail/initializer.hpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
6 // Copyright (c) 2002-2003
7 // Eric Friedman, Itay Maman
9 // Distributed under the Boost Software License, Version 1.0. (See
10 // accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
13 #ifndef BOOST_VARIANT_DETAIL_INITIALIZER_HPP
14 #define BOOST_VARIANT_DETAIL_INITIALIZER_HPP
16 #include <new> // for placement new
18 #include "boost/config.hpp"
20 #include "boost/call_traits.hpp"
21 #include "boost/detail/reference_content.hpp"
22 #include "boost/variant/recursive_wrapper_fwd.hpp"
24 #if !defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
25 # include "boost/mpl/aux_/value_wknd.hpp"
26 # include "boost/mpl/int.hpp"
27 # include "boost/mpl/iter_fold.hpp"
28 # include "boost/mpl/next.hpp"
29 # include "boost/mpl/deref.hpp"
30 # include "boost/mpl/pair.hpp"
31 # include "boost/mpl/protect.hpp"
33 # include "boost/variant/variant_fwd.hpp"
34 # include "boost/preprocessor/cat.hpp"
35 # include "boost/preprocessor/enum.hpp"
36 # include "boost/preprocessor/repeat.hpp"
40 namespace detail { namespace variant {
42 ///////////////////////////////////////////////////////////////////////////////
43 // (detail) support to simulate standard overload resolution rules
45 // The below initializers allows variant to follow standard overload
46 // resolution rules over the specified set of bounded types.
48 // On compilers where using declarations in class templates can correctly
49 // avoid name hiding, use an optimal solution based on the variant's typelist.
51 // Otherwise, use a preprocessor workaround based on knowledge of the fixed
52 // size of the variant's psuedo-variadic template parameter list.
55 #if !defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
57 // (detail) quoted metafunction make_initializer_node
59 // Exposes a pair whose first type is a node in the initializer hierarchy.
61 struct make_initializer_node
63 template <typename BaseIndexPair, typename Iterator>
66 private: // helpers, for metafunction result (below)
68 typedef typename BaseIndexPair::first
70 typedef typename BaseIndexPair::second
73 class initializer_node
76 private: // helpers, for static functions (below)
78 typedef typename mpl::deref<Iterator>::type
80 typedef typename unwrap_recursive<recursive_enabled_T>::type
82 typedef typename call_traits<public_T>::param_type
85 public: // static functions
87 using base::initialize;
89 static int initialize(void* dest, param_T operand)
91 typedef typename boost::detail::make_reference_content<
95 new(dest) internal_T(operand);
96 return BOOST_MPL_AUX_VALUE_WKND(index)::value; // which
101 friend class initializer_node;
103 public: // metafunction result
107 , typename mpl::next< index >::type
113 // (detail) class initializer_root
115 // Every level of the initializer hierarchy must expose the name
116 // "initialize," so initializer_root provides a dummy function:
118 class initializer_root
120 public: // static functions
122 static void initialize();
126 #else // defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
128 # if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
130 #define BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_PARAMS \
131 BOOST_VARIANT_ENUM_PARAMS(typename recursive_enabled_T) \
134 #define BOOST_VARIANT_AUX_PP_INITIALIZER_DEFINE_PARAM_T(N) \
135 typedef typename unwrap_recursive< \
136 BOOST_PP_CAT(recursive_enabled_T,N) \
137 >::type BOOST_PP_CAT(public_T,N); \
138 typedef typename call_traits< \
139 BOOST_PP_CAT(public_T,N) \
140 >::param_type BOOST_PP_CAT(param_T,N); \
143 # else // MSVC7 and below
145 #define BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_PARAMS \
146 BOOST_VARIANT_ENUM_PARAMS(typename recursive_enabled_T) \
147 , BOOST_VARIANT_ENUM_PARAMS(typename param_T) \
150 #define BOOST_VARIANT_AUX_PP_INITIALIZER_DEFINE_PARAM_T(N) \
153 # endif // MSVC7 and below workaround
155 template < BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_PARAMS >
156 struct preprocessor_list_initializer
158 public: // static functions
160 #define BOOST_VARIANT_AUX_PP_INITIALIZE_FUNCTION(z,N,_) \
161 BOOST_VARIANT_AUX_PP_INITIALIZER_DEFINE_PARAM_T(N) \
162 static int initialize( \
164 , BOOST_PP_CAT(param_T,N) operand \
167 typedef typename boost::detail::make_reference_content< \
168 BOOST_PP_CAT(recursive_enabled_T,N) \
169 >::type internal_T; \
171 new(dest) internal_T(operand); \
172 return (N); /*which*/ \
177 BOOST_VARIANT_LIMIT_TYPES
178 , BOOST_VARIANT_AUX_PP_INITIALIZE_FUNCTION
182 #undef BOOST_VARIANT_AUX_PP_INITIALIZE_FUNCTION
186 # if defined(BOOST_MPL_CFG_MSVC_60_ETI_BUG)
188 #if !defined(BOOST_VARIANT_AUX_ECHO)
189 # define BOOST_VARIANT_AUX_ECHO(z,N,token) token
193 struct preprocessor_list_initializer<
194 BOOST_PP_ENUM(BOOST_VARIANT_LIMIT_TYPES, BOOST_VARIANT_AUX_ECHO, int)
195 , BOOST_PP_ENUM(BOOST_VARIANT_LIMIT_TYPES, BOOST_VARIANT_AUX_ECHO, const int)
200 # endif // BOOST_MPL_CFG_MSVC_60_ETI_BUG workaround
202 #endif // BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE workaround
204 }} // namespace detail::variant
207 ///////////////////////////////////////////////////////////////////////////////
208 // macro BOOST_VARIANT_AUX_INITIALIZER_T
210 // Given both the variant's typelist and a basename for forming the list of
211 // bounded types (i.e., T becomes T1, T2, etc.), exposes the initializer
212 // most appropriate to the current compiler.
215 #if !defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
217 #define BOOST_VARIANT_AUX_INITIALIZER_T( mpl_seq, typename_base ) \
218 ::boost::mpl::iter_fold< \
220 , ::boost::mpl::pair< \
221 ::boost::detail::variant::initializer_root \
222 , ::boost::mpl::int_<0> \
224 , ::boost::mpl::protect< \
225 ::boost::detail::variant::make_initializer_node \
230 #else // defined(BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE)
232 # if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
234 #define BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_ARGS(typename_base) \
235 BOOST_VARIANT_ENUM_PARAMS(typename_base) \
238 # else // MSVC7 and below
240 #define BOOST_VARIANT_AUX_PP_INITIALIZER_ENUM_PARAM_TYPE(z,N,T) \
241 ::boost::call_traits< \
242 ::boost::unwrap_recursive<BOOST_PP_CAT(T,N)>::type \
246 #define BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_ARGS(typename_base) \
247 BOOST_VARIANT_ENUM_PARAMS(typename_base) \
249 BOOST_VARIANT_LIMIT_TYPES \
250 , BOOST_VARIANT_AUX_PP_INITIALIZER_ENUM_PARAM_TYPE \
255 # endif // MSVC7 workaround
257 #define BOOST_VARIANT_AUX_INITIALIZER_T( mpl_seq, typename_base ) \
258 ::boost::detail::variant::preprocessor_list_initializer< \
259 BOOST_VARIANT_AUX_PP_INITIALIZER_TEMPLATE_ARGS(typename_base) \
263 #endif // BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE workaround
265 #endif // BOOST_VARIANT_DETAIL_INITIALIZER_HPP