diff --git a/include/boost/mpl/aux_/begin_end_impl.hpp b/include/boost/mpl/aux_/begin_end_impl.hpp index f7723e9..b853ac3 100644 --- a/include/boost/mpl/aux_/begin_end_impl.hpp +++ b/include/boost/mpl/aux_/begin_end_impl.hpp @@ -93,8 +93,8 @@ AUX778076_IMPL_SPEC(end, na, void_) # undef AUX778076_IMPL_SPEC -BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1,begin_impl) -BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1,end_impl) +BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(1,begin_impl) +BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(1,end_impl) }} diff --git a/include/boost/mpl/aux_/push_back_impl.hpp b/include/boost/mpl/aux_/push_back_impl.hpp index 284b2c2..b4fe5e3 100644 --- a/include/boost/mpl/aux_/push_back_impl.hpp +++ b/include/boost/mpl/aux_/push_back_impl.hpp @@ -2,7 +2,7 @@ #ifndef BOOST_MPL_AUX_PUSH_BACK_IMPL_HPP_INCLUDED #define BOOST_MPL_AUX_PUSH_BACK_IMPL_HPP_INCLUDED -// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright Aleksey Gurtovoy 2000-2008 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -15,19 +15,35 @@ // $Revision$ #include +#include #include #include #include #include +#include + namespace boost { namespace mpl { +template< typename Tag > +struct has_push_back_impl; + // agurt 05/feb/04: no default implementation; the stub definition is needed // to enable the default 'has_push_back' implementation below template< typename Tag > struct push_back_impl { - template< typename Sequence, typename T > struct apply {}; + template< typename Sequence, typename T > struct apply + { + // should be instantiated only in the context of 'has_push_back_impl'; + // if you've got an assert here, you are requesting a 'push_back' + // specialization that doesn't exist. + BOOST_MPL_ASSERT_MSG( + ( boost::is_same< T, has_push_back_impl >::value ) + , REQUESTED_PUSH_BACK_SPECIALIZATION_FOR_SEQUENCE_DOES_NOT_EXIST + , ( Sequence ) + ); + }; }; template< typename Tag > @@ -35,13 +51,13 @@ struct has_push_back_impl { template< typename Seq > struct apply #if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING) - : aux::has_type< push_back > + : aux::has_type< push_back< Seq, has_push_back_impl > > { #else { - typedef aux::has_type< push_back > type; + typedef aux::has_type< push_back< Seq, has_push_back_impl > > type; BOOST_STATIC_CONSTANT(bool, value = - (aux::has_type< push_back >::value) + (aux::has_type< push_back< Seq, has_push_back_impl > >::value) ); #endif }; diff --git a/include/boost/mpl/aux_/push_front_impl.hpp b/include/boost/mpl/aux_/push_front_impl.hpp index a08d404..7de3ff7 100644 --- a/include/boost/mpl/aux_/push_front_impl.hpp +++ b/include/boost/mpl/aux_/push_front_impl.hpp @@ -2,7 +2,7 @@ #ifndef BOOST_MPL_AUX_PUSH_FRONT_IMPL_HPP_INCLUDED #define BOOST_MPL_AUX_PUSH_FRONT_IMPL_HPP_INCLUDED -// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright Aleksey Gurtovoy 2000-2008 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -15,20 +15,36 @@ // $Revision$ #include +#include #include #include #include #include +#include + namespace boost { namespace mpl { +template< typename Tag > +struct has_push_front_impl; + // agurt 05/feb/04: no default implementation; the stub definition is needed // to enable the default 'has_push_front' implementation below template< typename Tag > struct push_front_impl { - template< typename Sequence, typename T > struct apply {}; + template< typename Sequence, typename T > struct apply + { + // should be instantiated only in the context of 'has_push_front_impl'; + // if you've got an assert here, you are requesting a 'push_front' + // specialization that doesn't exist. + BOOST_MPL_ASSERT_MSG( + ( boost::is_same< T, has_push_front_impl >::value ) + , REQUESTED_PUSH_FRONT_SPECIALIZATION_FOR_SEQUENCE_DOES_NOT_EXIST + , ( Sequence ) + ); + }; }; template< typename Tag > @@ -36,13 +52,13 @@ struct has_push_front_impl { template< typename Seq > struct apply #if !defined(BOOST_MPL_CFG_NO_NESTED_FORWARDING) - : aux::has_type< push_front > + : aux::has_type< push_front< Seq, has_push_front_impl > > { #else { - typedef aux::has_type< push_front > type; + typedef aux::has_type< push_front< Seq, has_push_front_impl > > type; BOOST_STATIC_CONSTANT(bool, value = - (aux::has_type< push_front >::value) + (aux::has_type< push_front< Seq, has_push_front_impl > >::value) ); #endif }; diff --git a/include/boost/mpl/aux_/traits_lambda_spec.hpp b/include/boost/mpl/aux_/traits_lambda_spec.hpp index 4c82a65..0aee61f 100644 --- a/include/boost/mpl/aux_/traits_lambda_spec.hpp +++ b/include/boost/mpl/aux_/traits_lambda_spec.hpp @@ -2,7 +2,7 @@ #ifndef BOOST_MPL_AUX_TRAITS_LAMBDA_SPEC_HPP_INCLUDED #define BOOST_MPL_AUX_TRAITS_LAMBDA_SPEC_HPP_INCLUDED -// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright Aleksey Gurtovoy 2000-2008 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -14,17 +14,18 @@ // $Date$ // $Revision$ +#include #include #include #include #if !defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT) -# define BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(i, trait) /**/ +# define BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(i, trait) /**/ #elif !defined(BOOST_MPL_CFG_MSVC_ETI_BUG) -# define BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(i, trait) \ +# define BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(i, trait) \ template<> struct trait \ { \ template< BOOST_MPL_PP_PARAMS(i, typename T) > struct apply \ @@ -35,7 +36,7 @@ template<> struct trait \ #else -# define BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(i, trait) \ +# define BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(i, trait) \ template<> struct trait \ { \ template< BOOST_MPL_PP_PARAMS(i, typename T) > struct apply \ @@ -53,4 +54,10 @@ template<> struct trait \ #endif // BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT + +#define BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(i, trait) \ + BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(i, trait) \ + template<> struct trait {}; \ +/**/ + #endif // BOOST_MPL_AUX_TRAITS_LAMBDA_SPEC_HPP_INCLUDED diff --git a/include/boost/mpl/for_each.hpp b/include/boost/mpl/for_each.hpp index 79419e3..d03a65f 100644 --- a/include/boost/mpl/for_each.hpp +++ b/include/boost/mpl/for_each.hpp @@ -2,7 +2,7 @@ #ifndef BOOST_MPL_FOR_EACH_HPP_INCLUDED #define BOOST_MPL_FOR_EACH_HPP_INCLUDED -// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright Aleksey Gurtovoy 2000-2008 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -14,12 +14,14 @@ // $Date$ // $Revision$ +#include #include #include #include #include #include #include +#include #include #include @@ -90,6 +92,8 @@ template< inline void for_each(F f, Sequence* = 0, TransformOp* = 0) { + BOOST_MPL_ASSERT(( is_sequence )); + typedef typename begin::type first; typedef typename end::type last;