Chris@16: Chris@16: #ifndef BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED Chris@16: #define BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED Chris@16: Chris@16: // Copyright Aleksey Gurtovoy 2000-2004 Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/mpl for documentation. Chris@16: Chris@101: // $Id$ Chris@101: // $Date$ Chris@101: // $Revision$ Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace mpl { Chris@16: Chris@16: Chris@16: namespace aux { Chris@16: Chris@16: template< typename Sequence > Chris@16: struct begin_type Chris@16: { Chris@16: typedef typename Sequence::begin type; Chris@16: }; Chris@16: template< typename Sequence > Chris@16: struct end_type Chris@16: { Chris@16: typedef typename Sequence::end type; Chris@16: }; Chris@16: Chris@16: } Chris@16: Chris@16: // default implementation; conrete sequences might override it by Chris@16: // specializing either the 'begin_impl/end_impl' or the primary Chris@16: // 'begin/end' templates Chris@16: Chris@16: template< typename Tag > Chris@16: struct begin_impl Chris@16: { Chris@16: template< typename Sequence > struct apply Chris@16: { Chris@16: typedef typename eval_if, Chris@16: aux::begin_type, void_>::type type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: template< typename Tag > Chris@16: struct end_impl Chris@16: { Chris@16: template< typename Sequence > struct apply Chris@16: { Chris@16: typedef typename eval_if, Chris@16: aux::end_type, void_>::type type; Chris@16: }; Chris@16: }; Chris@16: Chris@16: // specialize 'begin_trait/end_trait' for two pre-defined tags Chris@16: Chris@16: # define AUX778076_IMPL_SPEC(name, tag, result) \ Chris@16: template<> \ Chris@16: struct name##_impl \ Chris@16: { \ Chris@16: template< typename Sequence > struct apply \ Chris@16: { \ Chris@16: typedef result type; \ Chris@16: }; \ Chris@16: }; \ Chris@16: /**/ Chris@16: Chris@16: // a sequence with nested 'begin/end' typedefs; just query them Chris@16: AUX778076_IMPL_SPEC(begin, nested_begin_end_tag, typename Sequence::begin) Chris@16: AUX778076_IMPL_SPEC(end, nested_begin_end_tag, typename Sequence::end) Chris@16: Chris@16: // if a type 'T' does not contain 'begin/end' or 'tag' members Chris@16: // and doesn't specialize either 'begin/end' or 'begin_impl/end_impl' Chris@16: // templates, then we end up here Chris@16: AUX778076_IMPL_SPEC(begin, non_sequence_tag, void_) Chris@16: AUX778076_IMPL_SPEC(end, non_sequence_tag, void_) Chris@16: AUX778076_IMPL_SPEC(begin, na, void_) Chris@16: AUX778076_IMPL_SPEC(end, na, void_) Chris@16: Chris@16: # undef AUX778076_IMPL_SPEC Chris@16: Chris@16: Chris@16: BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(1,begin_impl) Chris@16: BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(1,end_impl) Chris@16: Chris@16: }} Chris@16: Chris@16: #endif // BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED