Chris@16
|
1 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 /// \file pack.hpp
|
Chris@16
|
3 /// Contains helpers for pseudo-pack expansion.
|
Chris@16
|
4 //
|
Chris@16
|
5 // Copyright 2012 Eric Niebler. Distributed under the Boost
|
Chris@16
|
6 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
7 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8
|
Chris@16
|
9 #ifndef BOOST_PROTO_TRANSFORM_DETAIL_PACK_HPP_EAN_2012_07_11
|
Chris@16
|
10 #define BOOST_PROTO_TRANSFORM_DETAIL_PACK_HPP_EAN_2012_07_11
|
Chris@16
|
11
|
Chris@16
|
12 #include <boost/preprocessor/cat.hpp>
|
Chris@16
|
13 #include <boost/preprocessor/arithmetic/inc.hpp>
|
Chris@16
|
14 #include <boost/preprocessor/arithmetic/dec.hpp>
|
Chris@16
|
15 #include <boost/preprocessor/arithmetic/sub.hpp>
|
Chris@16
|
16 #include <boost/preprocessor/punctuation/comma_if.hpp>
|
Chris@16
|
17 #include <boost/preprocessor/repetition/enum.hpp>
|
Chris@16
|
18 #include <boost/preprocessor/repetition/enum_params.hpp>
|
Chris@16
|
19 #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
|
Chris@16
|
20 #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
|
Chris@16
|
21 #include <boost/preprocessor/repetition/repeat.hpp>
|
Chris@16
|
22 #include <boost/preprocessor/iteration/local.hpp>
|
Chris@16
|
23 #include <boost/preprocessor/iteration/iterate.hpp>
|
Chris@16
|
24 #include <boost/mpl/bool.hpp>
|
Chris@16
|
25 #include <boost/mpl/assert.hpp>
|
Chris@16
|
26 #include <boost/type_traits/is_same.hpp>
|
Chris@16
|
27 #include <boost/proto/proto_fwd.hpp>
|
Chris@16
|
28
|
Chris@101
|
29 #if defined(_MSC_VER)
|
Chris@16
|
30 # pragma warning(push)
|
Chris@16
|
31 # pragma warning(disable: 4348) // redefinition of default parameter
|
Chris@16
|
32 #endif
|
Chris@16
|
33
|
Chris@16
|
34 namespace boost { namespace proto
|
Chris@16
|
35 {
|
Chris@16
|
36 namespace detail
|
Chris@16
|
37 {
|
Chris@16
|
38 template<typename Fun>
|
Chris@16
|
39 struct msvc_fun_workaround;
|
Chris@16
|
40
|
Chris@16
|
41 template<typename Tfx, typename T>
|
Chris@16
|
42 struct expand_pattern_helper
|
Chris@16
|
43 {
|
Chris@16
|
44 typedef T type;
|
Chris@16
|
45 typedef mpl::false_ applied;
|
Chris@16
|
46 };
|
Chris@16
|
47
|
Chris@16
|
48 template<typename Tfx, typename Fun>
|
Chris@16
|
49 struct expand_pattern_helper<Tfx, Fun *>
|
Chris@16
|
50 : expand_pattern_helper<Tfx, Fun>
|
Chris@16
|
51 {};
|
Chris@16
|
52
|
Chris@16
|
53 template<typename Tfx, typename T>
|
Chris@16
|
54 struct expand_pattern_helper<Tfx, pack(T)>
|
Chris@16
|
55 {
|
Chris@16
|
56 // BUGBUG fix me. See comment in transform/detail/call.hpp
|
Chris@16
|
57 BOOST_MPL_ASSERT_MSG(
|
Chris@16
|
58 (is_same<T, _>::value)
|
Chris@16
|
59 , PACK_EXPANSIONS_OF_EXPRESSIONS_OTHER_THAN_THE_CURRENT_NOT_YET_SUPPORTED
|
Chris@16
|
60 , (T)
|
Chris@16
|
61 );
|
Chris@16
|
62 typedef Tfx type(T);
|
Chris@16
|
63 typedef mpl::true_ applied;
|
Chris@16
|
64 };
|
Chris@16
|
65
|
Chris@16
|
66 template<typename Tfx>
|
Chris@16
|
67 struct expand_pattern_helper<Tfx, pack(_)>
|
Chris@16
|
68 {
|
Chris@16
|
69 typedef Tfx type;
|
Chris@16
|
70 typedef mpl::true_ applied;
|
Chris@16
|
71 };
|
Chris@16
|
72
|
Chris@16
|
73 #include <boost/proto/transform/detail/expand_pack.hpp>
|
Chris@16
|
74
|
Chris@16
|
75 template<long Arity, typename Fun, typename Cont>
|
Chris@16
|
76 struct expand_pattern;
|
Chris@16
|
77
|
Chris@16
|
78 template<typename Fun, typename Cont>
|
Chris@16
|
79 struct expand_pattern<0, Fun, Cont>
|
Chris@16
|
80 : Cont::template cat<typename expand_pattern_helper<proto::_value, Fun>::type>
|
Chris@16
|
81 {
|
Chris@16
|
82 BOOST_MPL_ASSERT_MSG(
|
Chris@16
|
83 (expand_pattern_helper<proto::_value, Fun>::applied::value)
|
Chris@16
|
84 , NO_PACK_EXPRESSION_FOUND_IN_PACK_EXPANSION
|
Chris@16
|
85 , (Fun)
|
Chris@16
|
86 );
|
Chris@16
|
87 };
|
Chris@16
|
88
|
Chris@16
|
89 #include <boost/proto/transform/detail/pack_impl.hpp>
|
Chris@16
|
90 }
|
Chris@16
|
91 }}
|
Chris@16
|
92
|
Chris@101
|
93 #if defined(_MSC_VER)
|
Chris@16
|
94 # pragma warning(pop)
|
Chris@16
|
95 #endif
|
Chris@16
|
96
|
Chris@16
|
97 #endif
|