1 | /*=============================================================================
|
---|
2 | Copyright (c) 2003 Joel de Guzman
|
---|
3 | Copyright (c) 2004 Peder Holt
|
---|
4 |
|
---|
5 | Use, modification and distribution is subject to the Boost Software
|
---|
6 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
7 | http://www.boost.org/LICENSE_1_0.txt)
|
---|
8 | ==============================================================================*/
|
---|
9 | #if !defined(FUSION_SEQUENCE_BEGIN_HPP)
|
---|
10 | #define FUSION_SEQUENCE_BEGIN_HPP
|
---|
11 |
|
---|
12 | #include <boost/spirit/fusion/detail/config.hpp>
|
---|
13 | #include <boost/spirit/fusion/sequence/as_fusion_sequence.hpp>
|
---|
14 | #include <boost/type_traits/is_const.hpp>
|
---|
15 | namespace boost { namespace fusion
|
---|
16 | {
|
---|
17 | namespace meta
|
---|
18 | {
|
---|
19 | template <typename Tag>
|
---|
20 | struct begin_impl
|
---|
21 | {
|
---|
22 | template <typename Sequence>
|
---|
23 | struct apply {
|
---|
24 | typedef int type;
|
---|
25 | };
|
---|
26 | };
|
---|
27 |
|
---|
28 | template <typename Sequence>
|
---|
29 | struct begin
|
---|
30 | {
|
---|
31 | typedef as_fusion_sequence<Sequence> seq_converter;
|
---|
32 | typedef typename seq_converter::type seq;
|
---|
33 |
|
---|
34 | typedef typename
|
---|
35 | begin_impl<typename seq::tag>::
|
---|
36 | template apply<seq>::type
|
---|
37 | type;
|
---|
38 | };
|
---|
39 | }
|
---|
40 |
|
---|
41 | #if BOOST_WORKAROUND(BOOST_MSVC,<=1300)
|
---|
42 | namespace detail {
|
---|
43 | template <typename Sequence>
|
---|
44 | inline typename meta::begin<Sequence const>::type
|
---|
45 | begin(Sequence const& seq,mpl::bool_<true>)
|
---|
46 | {
|
---|
47 | typedef meta::begin<Sequence const> begin_meta;
|
---|
48 | return meta::begin_impl<BOOST_DEDUCED_TYPENAME begin_meta::seq::tag>::
|
---|
49 | template apply<BOOST_DEDUCED_TYPENAME begin_meta::seq const>::call(
|
---|
50 | begin_meta::seq_converter::convert_const(seq));
|
---|
51 | }
|
---|
52 |
|
---|
53 | template <typename Sequence>
|
---|
54 | inline typename meta::begin<Sequence>::type
|
---|
55 | begin(Sequence& seq,mpl::bool_<false>)
|
---|
56 | {
|
---|
57 | typedef meta::begin<Sequence> begin_meta;
|
---|
58 | return meta::begin_impl<BOOST_DEDUCED_TYPENAME begin_meta::seq::tag>::
|
---|
59 | template apply<BOOST_DEDUCED_TYPENAME begin_meta::seq>::call(
|
---|
60 | begin_meta::seq_converter::convert(seq));
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | template <typename Sequence>
|
---|
65 | inline typename meta::begin<Sequence>::type
|
---|
66 | begin(Sequence& seq)
|
---|
67 | {
|
---|
68 | return detail::begin(seq,is_const<Sequence>());
|
---|
69 | }
|
---|
70 | #else
|
---|
71 | template <typename Sequence>
|
---|
72 | inline typename meta::begin<Sequence const>::type
|
---|
73 | begin(Sequence const& seq)
|
---|
74 | {
|
---|
75 | typedef meta::begin<Sequence const> begin_meta;
|
---|
76 | return meta::begin_impl<typename begin_meta::seq::tag>::
|
---|
77 | template apply<typename begin_meta::seq const>::call(
|
---|
78 | begin_meta::seq_converter::convert_const(seq));
|
---|
79 | }
|
---|
80 |
|
---|
81 | template <typename Sequence>
|
---|
82 | inline typename meta::begin<Sequence>::type
|
---|
83 | begin(Sequence& seq)
|
---|
84 | {
|
---|
85 | typedef meta::begin<Sequence> begin_meta;
|
---|
86 | return meta::begin_impl<typename begin_meta::seq::tag>::
|
---|
87 | template apply<typename begin_meta::seq>::call(
|
---|
88 | begin_meta::seq_converter::convert(seq));
|
---|
89 | }
|
---|
90 | #endif
|
---|
91 | }}
|
---|
92 |
|
---|
93 | #endif
|
---|