source: NonGTP/Boost/boost/mpl/aux_/begin_end_impl.hpp @ 857

Revision 857, 2.3 KB checked in by igarcia, 19 years ago (diff)
Line 
1
2#ifndef BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED
3#define BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED
4
5// Copyright Aleksey Gurtovoy 2000-2004
6//
7// Distributed under the Boost Software License, Version 1.0.
8// (See accompanying file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10//
11// See http://www.boost.org/libs/mpl for documentation.
12
13// $Source: /cvsroot/boost/boost/boost/mpl/aux_/begin_end_impl.hpp,v $
14// $Date: 2004/09/02 15:40:43 $
15// $Revision: 1.8 $
16
17#include <boost/mpl/begin_end_fwd.hpp>
18#include <boost/mpl/sequence_tag_fwd.hpp>
19#include <boost/mpl/void.hpp>
20#include <boost/mpl/aux_/na.hpp>
21#include <boost/mpl/aux_/traits_lambda_spec.hpp>
22#include <boost/mpl/aux_/config/eti.hpp>
23
24namespace boost { namespace mpl {
25
26// default implementation; conrete sequences might override it by
27// specializing either the 'begin_impl/end_impl' or the primary
28// 'begin/end' templates
29
30template< typename Tag >
31struct begin_impl
32{
33    template< typename Sequence > struct apply
34    {
35        typedef typename Sequence::begin type;
36    };
37};
38
39template< typename Tag >
40struct end_impl
41{
42    template< typename Sequence > struct apply
43    {
44        typedef typename Sequence::end type;
45    };
46};
47
48// specialize 'begin_trait/end_trait' for two pre-defined tags
49
50#   define AUX778076_IMPL_SPEC(name, tag, result) \
51template<> \
52struct name##_impl<tag> \
53{ \
54    template< typename Sequence > struct apply \
55    { \
56        typedef result type; \
57    }; \
58}; \
59/**/
60
61// a sequence with nested 'begin/end' typedefs; just query them
62AUX778076_IMPL_SPEC(begin, nested_begin_end_tag, typename Sequence::begin)
63AUX778076_IMPL_SPEC(end, nested_begin_end_tag, typename Sequence::end)
64
65// if a type 'T' does not contain 'begin/end' or 'tag' members
66// and doesn't specialize either 'begin/end' or 'begin_impl/end_impl'
67// templates, then we end up here
68AUX778076_IMPL_SPEC(begin, non_sequence_tag, void_)
69AUX778076_IMPL_SPEC(end, non_sequence_tag, void_)
70AUX778076_IMPL_SPEC(begin, na, void_)
71AUX778076_IMPL_SPEC(end, na, void_)
72
73#   undef AUX778076_IMPL_SPEC
74
75
76BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1,begin_impl)
77BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1,end_impl)
78
79}}
80
81#endif // BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.