Chris@16
|
1
|
Chris@16
|
2 #ifndef BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|
Chris@16
|
3 #define BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|
Chris@16
|
4
|
Chris@16
|
5 // Copyright Aleksey Gurtovoy 2000-2004
|
Chris@16
|
6 //
|
Chris@16
|
7 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
8 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
9 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
10 //
|
Chris@16
|
11 // See http://www.boost.org/libs/mpl for documentation.
|
Chris@16
|
12
|
Chris@101
|
13 // $Id$
|
Chris@101
|
14 // $Date$
|
Chris@101
|
15 // $Revision$
|
Chris@16
|
16
|
Chris@16
|
17 #include <boost/mpl/begin_end_fwd.hpp>
|
Chris@16
|
18 #include <boost/mpl/sequence_tag_fwd.hpp>
|
Chris@16
|
19 #include <boost/mpl/void.hpp>
|
Chris@16
|
20 #include <boost/mpl/eval_if.hpp>
|
Chris@16
|
21 #include <boost/mpl/aux_/has_begin.hpp>
|
Chris@16
|
22 #include <boost/mpl/aux_/na.hpp>
|
Chris@16
|
23 #include <boost/mpl/aux_/traits_lambda_spec.hpp>
|
Chris@16
|
24 #include <boost/mpl/aux_/config/eti.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 namespace boost { namespace mpl {
|
Chris@16
|
27
|
Chris@16
|
28
|
Chris@16
|
29 namespace aux {
|
Chris@16
|
30
|
Chris@16
|
31 template< typename Sequence >
|
Chris@16
|
32 struct begin_type
|
Chris@16
|
33 {
|
Chris@16
|
34 typedef typename Sequence::begin type;
|
Chris@16
|
35 };
|
Chris@16
|
36 template< typename Sequence >
|
Chris@16
|
37 struct end_type
|
Chris@16
|
38 {
|
Chris@16
|
39 typedef typename Sequence::end type;
|
Chris@16
|
40 };
|
Chris@16
|
41
|
Chris@16
|
42 }
|
Chris@16
|
43
|
Chris@16
|
44 // default implementation; conrete sequences might override it by
|
Chris@16
|
45 // specializing either the 'begin_impl/end_impl' or the primary
|
Chris@16
|
46 // 'begin/end' templates
|
Chris@16
|
47
|
Chris@16
|
48 template< typename Tag >
|
Chris@16
|
49 struct begin_impl
|
Chris@16
|
50 {
|
Chris@16
|
51 template< typename Sequence > struct apply
|
Chris@16
|
52 {
|
Chris@16
|
53 typedef typename eval_if<aux::has_begin<Sequence, true_>,
|
Chris@16
|
54 aux::begin_type<Sequence>, void_>::type type;
|
Chris@16
|
55 };
|
Chris@16
|
56 };
|
Chris@16
|
57
|
Chris@16
|
58 template< typename Tag >
|
Chris@16
|
59 struct end_impl
|
Chris@16
|
60 {
|
Chris@16
|
61 template< typename Sequence > struct apply
|
Chris@16
|
62 {
|
Chris@16
|
63 typedef typename eval_if<aux::has_begin<Sequence, true_>,
|
Chris@16
|
64 aux::end_type<Sequence>, void_>::type type;
|
Chris@16
|
65 };
|
Chris@16
|
66 };
|
Chris@16
|
67
|
Chris@16
|
68 // specialize 'begin_trait/end_trait' for two pre-defined tags
|
Chris@16
|
69
|
Chris@16
|
70 # define AUX778076_IMPL_SPEC(name, tag, result) \
|
Chris@16
|
71 template<> \
|
Chris@16
|
72 struct name##_impl<tag> \
|
Chris@16
|
73 { \
|
Chris@16
|
74 template< typename Sequence > struct apply \
|
Chris@16
|
75 { \
|
Chris@16
|
76 typedef result type; \
|
Chris@16
|
77 }; \
|
Chris@16
|
78 }; \
|
Chris@16
|
79 /**/
|
Chris@16
|
80
|
Chris@16
|
81 // a sequence with nested 'begin/end' typedefs; just query them
|
Chris@16
|
82 AUX778076_IMPL_SPEC(begin, nested_begin_end_tag, typename Sequence::begin)
|
Chris@16
|
83 AUX778076_IMPL_SPEC(end, nested_begin_end_tag, typename Sequence::end)
|
Chris@16
|
84
|
Chris@16
|
85 // if a type 'T' does not contain 'begin/end' or 'tag' members
|
Chris@16
|
86 // and doesn't specialize either 'begin/end' or 'begin_impl/end_impl'
|
Chris@16
|
87 // templates, then we end up here
|
Chris@16
|
88 AUX778076_IMPL_SPEC(begin, non_sequence_tag, void_)
|
Chris@16
|
89 AUX778076_IMPL_SPEC(end, non_sequence_tag, void_)
|
Chris@16
|
90 AUX778076_IMPL_SPEC(begin, na, void_)
|
Chris@16
|
91 AUX778076_IMPL_SPEC(end, na, void_)
|
Chris@16
|
92
|
Chris@16
|
93 # undef AUX778076_IMPL_SPEC
|
Chris@16
|
94
|
Chris@16
|
95
|
Chris@16
|
96 BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(1,begin_impl)
|
Chris@16
|
97 BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(1,end_impl)
|
Chris@16
|
98
|
Chris@16
|
99 }}
|
Chris@16
|
100
|
Chris@16
|
101 #endif // BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|