mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-03 06:44:37 +02:00
Proper (well, better) diagnostics for passing non-sequence types to sequence algoritms/metafunctions, see http://thread.gmane.org/gmane.comp.lib.boost.user/36876
[SVN r46546]
This commit is contained in:
@@ -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)
|
||||
|
||||
}}
|
||||
|
||||
|
@@ -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 <boost/mpl/push_back_fwd.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/aux_/has_type.hpp>
|
||||
#include <boost/mpl/aux_/traits_lambda_spec.hpp>
|
||||
#include <boost/mpl/aux_/config/forwarding.hpp>
|
||||
#include <boost/mpl/aux_/config/static_constant.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
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<T> >::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<Seq,int> >
|
||||
: aux::has_type< push_back< Seq, has_push_back_impl<Tag> > >
|
||||
{
|
||||
#else
|
||||
{
|
||||
typedef aux::has_type< push_back<Seq,int> > type;
|
||||
typedef aux::has_type< push_back< Seq, has_push_back_impl<Tag> > > type;
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
(aux::has_type< push_back<Seq,int> >::value)
|
||||
(aux::has_type< push_back< Seq, has_push_back_impl<Tag> > >::value)
|
||||
);
|
||||
#endif
|
||||
};
|
||||
|
@@ -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 <boost/mpl/push_front_fwd.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/aux_/has_type.hpp>
|
||||
#include <boost/mpl/aux_/traits_lambda_spec.hpp>
|
||||
#include <boost/mpl/aux_/config/forwarding.hpp>
|
||||
#include <boost/mpl/aux_/config/static_constant.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
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<T> >::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<Seq,int> >
|
||||
: aux::has_type< push_front< Seq, has_push_front_impl<Tag> > >
|
||||
{
|
||||
#else
|
||||
{
|
||||
typedef aux::has_type< push_front<Seq,int> > type;
|
||||
typedef aux::has_type< push_front< Seq, has_push_front_impl<Tag> > > type;
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
(aux::has_type< push_front<Seq,int> >::value)
|
||||
(aux::has_type< push_front< Seq, has_push_front_impl<Tag> > >::value)
|
||||
);
|
||||
#endif
|
||||
};
|
||||
|
@@ -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 <boost/mpl/sequence_tag_fwd.hpp>
|
||||
#include <boost/mpl/void.hpp>
|
||||
#include <boost/mpl/aux_/preprocessor/params.hpp>
|
||||
#include <boost/mpl/aux_/config/lambda.hpp>
|
||||
|
||||
#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<void_> \
|
||||
{ \
|
||||
template< BOOST_MPL_PP_PARAMS(i, typename T) > struct apply \
|
||||
@@ -35,7 +36,7 @@ template<> struct trait<void_> \
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(i, trait) \
|
||||
# define BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC_IMPL(i, trait) \
|
||||
template<> struct trait<void_> \
|
||||
{ \
|
||||
template< BOOST_MPL_PP_PARAMS(i, typename T) > struct apply \
|
||||
@@ -53,4 +54,10 @@ template<> struct trait<int> \
|
||||
|
||||
#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<non_sequence_tag> {}; \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_MPL_AUX_TRAITS_LAMBDA_SPEC_HPP_INCLUDED
|
||||
|
@@ -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 <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/apply.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/next_prior.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/aux_/unwrap.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
@@ -90,6 +92,8 @@ template<
|
||||
inline
|
||||
void for_each(F f, Sequence* = 0, TransformOp* = 0)
|
||||
{
|
||||
BOOST_MPL_ASSERT(( is_sequence<Sequence> ));
|
||||
|
||||
typedef typename begin<Sequence>::type first;
|
||||
typedef typename end<Sequence>::type last;
|
||||
|
||||
|
Reference in New Issue
Block a user