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