Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:41:37

0001 
0002 #ifndef BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED
0003 #define BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED
0004 
0005 // Copyright Aleksey Gurtovoy 2000-2004
0006 //
0007 // Distributed under the Boost Software License, Version 1.0.
0008 // (See accompanying file LICENSE_1_0.txt or copy at 
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 // See http://www.boost.org/libs/mpl for documentation.
0012 
0013 // $Id$
0014 // $Date$
0015 // $Revision$
0016 
0017 #include <boost/mpl/begin_end_fwd.hpp>
0018 #include <boost/mpl/sequence_tag_fwd.hpp>
0019 #include <boost/mpl/void.hpp>
0020 #include <boost/mpl/eval_if.hpp>
0021 #include <boost/mpl/aux_/has_begin.hpp>
0022 #include <boost/mpl/aux_/na.hpp>
0023 #include <boost/mpl/aux_/traits_lambda_spec.hpp>
0024 #include <boost/mpl/aux_/config/eti.hpp>
0025 
0026 namespace boost { namespace mpl {
0027 
0028 
0029 namespace aux { 
0030 
0031 template< typename Sequence > 
0032 struct begin_type 
0033 { 
0034     typedef typename Sequence::begin type; 
0035 };
0036 template< typename Sequence > 
0037 struct end_type
0038 { 
0039     typedef typename Sequence::end type; 
0040 };
0041 
0042 }
0043 
0044 // default implementation; conrete sequences might override it by 
0045 // specializing either the 'begin_impl/end_impl' or the primary 
0046 // 'begin/end' templates
0047 
0048 template< typename Tag >
0049 struct begin_impl
0050 {
0051     template< typename Sequence > struct apply
0052     {
0053         typedef typename eval_if<aux::has_begin<Sequence, true_>,
0054                                  aux::begin_type<Sequence>, void_>::type type;
0055     };
0056 };
0057 
0058 template< typename Tag >
0059 struct end_impl
0060 {
0061     template< typename Sequence > struct apply
0062     {
0063         typedef typename eval_if<aux::has_begin<Sequence, true_>,
0064                                  aux::end_type<Sequence>, void_>::type type;
0065     };
0066 };
0067 
0068 // specialize 'begin_trait/end_trait' for two pre-defined tags
0069 
0070 #   define AUX778076_IMPL_SPEC(name, tag, result) \
0071 template<> \
0072 struct name##_impl<tag> \
0073 { \
0074     template< typename Sequence > struct apply \
0075     { \
0076         typedef result type; \
0077     }; \
0078 }; \
0079 /**/
0080 
0081 // a sequence with nested 'begin/end' typedefs; just query them
0082 AUX778076_IMPL_SPEC(begin, nested_begin_end_tag, typename Sequence::begin)
0083 AUX778076_IMPL_SPEC(end, nested_begin_end_tag, typename Sequence::end)
0084 
0085 // if a type 'T' does not contain 'begin/end' or 'tag' members 
0086 // and doesn't specialize either 'begin/end' or 'begin_impl/end_impl' 
0087 // templates, then we end up here
0088 AUX778076_IMPL_SPEC(begin, non_sequence_tag, void_)
0089 AUX778076_IMPL_SPEC(end, non_sequence_tag, void_)
0090 AUX778076_IMPL_SPEC(begin, na, void_)
0091 AUX778076_IMPL_SPEC(end, na, void_)
0092 
0093 #   undef AUX778076_IMPL_SPEC
0094 
0095 
0096 BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(1,begin_impl)
0097 BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(1,end_impl)
0098 
0099 }}
0100 
0101 #endif // BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED