source: NonGTP/Boost/boost/spirit/fusion/sequence/detail/cons_begin_end_traits.hpp @ 857

Revision 857, 2.5 KB checked in by igarcia, 18 years ago (diff)
Line 
1/*=============================================================================
2    Copyright (c) 2003 Joel de Guzman
3    Copyright (c) 2004 Peder Holt
4    Copyright (c) 2005 Eric Niebler
5
6    Use, modification and distribution is subject to the Boost Software
7    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8    http://www.boost.org/LICENSE_1_0.txt)
9==============================================================================*/
10#if !defined(FUSION_SEQUENCE_DETAIL_CONS_BEGIN_END_TRAITS_HPP)
11#define FUSION_SEQUENCE_DETAIL_CONS_BEGIN_END_TRAITS_HPP
12
13#include <boost/spirit/fusion/detail/config.hpp>
14#include <boost/mpl/if.hpp>
15#include <boost/type_traits/is_const.hpp>
16
17namespace boost { namespace fusion
18{
19    struct nil;
20
21    struct cons_tag;
22
23    template <typename Car, typename Cdr>
24    struct cons;
25
26    template <typename Cons>
27    struct cons_iterator;
28
29    namespace cons_detail
30    {
31        template <typename Cons>
32        struct begin_traits_impl
33        {
34            typedef cons_iterator<Cons> type;
35
36            static type
37            call(Cons& t)
38            {
39                return type(t);
40            }
41        };
42
43        template <typename Cons>
44        struct end_traits_impl
45        {
46            typedef cons_iterator<
47                typename mpl::if_<is_const<Cons>, nil const, nil>::type>
48            type;
49
50            static type
51            call(Cons&)
52            {
53                FUSION_RETURN_DEFAULT_CONSTRUCTED;
54            }
55        };
56    }
57
58    namespace meta
59    {
60        template <typename Tag>
61        struct begin_impl;
62
63        template <>
64        struct begin_impl<cons_tag>
65        {
66            template <typename Sequence>
67            struct apply : cons_detail::begin_traits_impl<Sequence>
68            {};
69        };
70
71        template <typename Tag>
72        struct end_impl;
73
74        template <>
75        struct end_impl<cons_tag>
76        {
77            template <typename Sequence>
78            struct apply : cons_detail::end_traits_impl<Sequence>
79            {};
80        };
81    }
82}}
83
84namespace boost { namespace mpl
85{
86    template <typename Tag>
87    struct begin_impl;
88
89    template <typename Tag>
90    struct end_impl;
91
92    template <>
93    struct begin_impl<fusion::cons_tag>
94        : fusion::meta::begin_impl<fusion::cons_tag> {};
95
96    template <>
97    struct end_impl<fusion::cons_tag>
98        : fusion::meta::end_impl<fusion::cons_tag> {};
99}}
100
101#endif
Note: See TracBrowser for help on using the repository browser.