mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-03 14:54:30 +02:00
is_sequence initial checkin
[SVN r16398]
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#define BOOST_MPL_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|
||||
|
||||
#include "boost/mpl/begin_end_fwd.hpp"
|
||||
#include "boost/mpl/sequence_tag_fwd.hpp"
|
||||
#include "boost/mpl/aux_/traits_lambda_spec.hpp"
|
||||
#include "boost/mpl/aux_/config/eti.hpp"
|
||||
|
||||
@@ -25,8 +26,8 @@ namespace boost {
|
||||
namespace mpl {
|
||||
|
||||
// default implementation; conrete sequences might override it by
|
||||
// specializing either the |begin_traits/end_traits| or the primary
|
||||
// |begin/end| templates
|
||||
// specializing either the 'begin_traits/end_traits' or the primary
|
||||
// 'begin/end' templates
|
||||
|
||||
template< typename Tag >
|
||||
struct begin_traits
|
||||
@@ -46,24 +47,37 @@ struct end_traits
|
||||
};
|
||||
};
|
||||
|
||||
#if defined(BOOST_MPL_MSVC_ETI_BUG)
|
||||
template<> struct begin_traits<int>
|
||||
{
|
||||
template< typename Sequence > struct algorithm
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
};
|
||||
// specialize 'begin_trait/end_trait' for two pre-defined tags
|
||||
|
||||
template<> struct end_traits<int>
|
||||
{
|
||||
template< typename Sequence > struct algorithm
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
};
|
||||
# define AUX_AGLORITM_TRAIT_SPEC(name, tag, result) \
|
||||
template<> \
|
||||
struct name##_traits<tag> \
|
||||
{ \
|
||||
template< typename Sequence > struct algorithm \
|
||||
{ \
|
||||
typedef result type; \
|
||||
}; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
// a sequence with nested 'begin/end' typedefs; just query them
|
||||
AUX_AGLORITM_TRAIT_SPEC(begin, nested_begin_end_tag, typename Sequence::begin)
|
||||
AUX_AGLORITM_TRAIT_SPEC(end, nested_begin_end_tag, typename Sequence::end)
|
||||
|
||||
// if a type 'T' does not contain 'begin/end' or 'tag' members
|
||||
// and doesn't specialize either 'begin/end' or 'begin_traits/end_traits'
|
||||
// templates, then we end up here
|
||||
AUX_AGLORITM_TRAIT_SPEC(begin, non_sequence_tag, non_sequence_tag)
|
||||
AUX_AGLORITM_TRAIT_SPEC(end, non_sequence_tag, non_sequence_tag)
|
||||
|
||||
#if defined(BOOST_MPL_MSVC_ETI_BUG)
|
||||
AUX_AGLORITM_TRAIT_SPEC(begin, int, non_sequence_tag)
|
||||
AUX_AGLORITM_TRAIT_SPEC(end, int, non_sequence_tag)
|
||||
#endif
|
||||
|
||||
# undef AUX_AGLORITM_TRAIT_SPEC
|
||||
|
||||
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1,begin_traits)
|
||||
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(1,end_traits)
|
||||
|
||||
|
26
include/boost/mpl/aux_/has_begin.hpp
Normal file
26
include/boost/mpl/aux_/has_begin.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost mpl/aux_/has_begin.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002
|
||||
// Aleksey Gurtovoy
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
|
||||
#ifndef BOOST_MPL_AUX_HAS_BEGIN_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_HAS_BEGIN_HPP_INCLUDED
|
||||
|
||||
#include "boost/mpl/aux_/has_xxx.hpp"
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_begin, begin, true)
|
||||
}}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_HAS_BEGIN_HPP_INCLUDED
|
@@ -24,7 +24,7 @@
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_rebind_impl, rebind)
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_rebind_impl, rebind, false)
|
||||
|
||||
template< typename T >
|
||||
struct has_rebind
|
||||
|
26
include/boost/mpl/aux_/has_tag.hpp
Normal file
26
include/boost/mpl/aux_/has_tag.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost mpl/aux_/has_tag.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002
|
||||
// Aleksey Gurtovoy
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
|
||||
#ifndef BOOST_MPL_AUX_HAS_TAG_HPP_INCLUDED
|
||||
#define BOOST_MPL_AUX_HAS_TAG_HPP_INCLUDED
|
||||
|
||||
#include "boost/mpl/aux_/has_xxx.hpp"
|
||||
|
||||
namespace boost { namespace mpl { namespace aux {
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_tag, tag, true)
|
||||
}}}
|
||||
|
||||
#endif // BOOST_MPL_AUX_HAS_TAG_HPP_INCLUDED
|
@@ -32,7 +32,7 @@
|
||||
// the implementation below is based on a USENET newsgroup's posting by
|
||||
// Rani Sharoni (comp.lang.c++.moderated, 2002-03-17 07:45:09 PST)
|
||||
|
||||
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name) \
|
||||
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, unused) \
|
||||
template< typename T > \
|
||||
boost::mpl::aux::yes_tag \
|
||||
trait##_helper( \
|
||||
@@ -66,7 +66,7 @@ namespace boost { namespace mpl { namespace aux {
|
||||
struct has_xxx_tag;
|
||||
}}}
|
||||
|
||||
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF_(trait, name) \
|
||||
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF_(trait, name, unused) \
|
||||
template< typename T, typename name = ::boost::mpl::aux::has_xxx_tag > \
|
||||
struct trait : T \
|
||||
{ \
|
||||
@@ -105,13 +105,13 @@ template<> struct trait<T,boost::mpl::aux::has_xxx_tag> \
|
||||
/**/
|
||||
|
||||
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
|
||||
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name) \
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF_(trait, name) \
|
||||
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, unused) \
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF_(trait, name, unused) \
|
||||
BOOST_MPL_AUX_HAS_XXX_TRAIT_SPEC(trait, wchar_t) \
|
||||
/**/
|
||||
#else
|
||||
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name) \
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF_(trait, name) \
|
||||
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, unused) \
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF_(trait, name, unused) \
|
||||
/**/
|
||||
#endif
|
||||
|
||||
@@ -119,18 +119,18 @@ template<> struct trait<T,boost::mpl::aux::has_xxx_tag> \
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name) \
|
||||
# define BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(trait, name, default_value) \
|
||||
template< typename T > \
|
||||
struct trait \
|
||||
{ \
|
||||
BOOST_STATIC_CONSTANT(bool, value = false); \
|
||||
BOOST_STATIC_CONSTANT(bool, value = default_value); \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_MPL_BROKEN_OVERLOAD_RESOLUTION
|
||||
|
||||
#define BOOST_MPL_HAS_XXX_TRAIT_DEF(name) \
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_##name, name) \
|
||||
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_##name, name, false) \
|
||||
/**/
|
||||
|
||||
#endif // BOOST_MPL_AUX_HAS_XXX_HPP_INCLUDED
|
||||
|
@@ -20,10 +20,14 @@
|
||||
//#include "boost/mpl/aux_/config/internal.hpp"
|
||||
#include "boost/config.hpp"
|
||||
|
||||
#if defined(BOOST_MPL_INTERNAL_USE_SEQUENCE_TAG) || \
|
||||
defined(BOOST_MSVC) && BOOST_MSVC < 1300
|
||||
# include "boost/mpl/sequence_tag.hpp"
|
||||
#if !defined(BOOST_MPL_INTERNAL_USE_SEQUENCE_TAG)
|
||||
# define BOOST_MPL_INTERNAL_USE_SEQUENCE_TAG
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MPL_INTERNAL_USE_SEQUENCE_TAG) \
|
||||
|| defined(BOOST_MSVC) && BOOST_MSVC < 1300
|
||||
|
||||
# include "boost/mpl/sequence_tag.hpp"
|
||||
# define BOOST_MPL_AUX_SEQUENCE_TAG(seq) sequence_tag<seq>::type
|
||||
|
||||
#else
|
||||
|
51
include/boost/mpl/is_sequence.hpp
Normal file
51
include/boost/mpl/is_sequence.hpp
Normal file
@@ -0,0 +1,51 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost mpl/is_sequence.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2002
|
||||
// Aleksey Gurtovoy
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
|
||||
#ifndef BOOST_MPL_IS_SEQUENCE_HPP_INCLUDED
|
||||
#define BOOST_MPL_IS_SEQUENCE_HPP_INCLUDED
|
||||
|
||||
#include "boost/mpl/logical/not.hpp"
|
||||
#include "boost/mpl/begin_end.hpp"
|
||||
#include "boost/mpl/sequence_tag_fwd.hpp"
|
||||
#include "boost/mpl/aux_/void_spec.hpp"
|
||||
#include "boost/mpl/aux_/lambda_support.hpp"
|
||||
#include "boost/mpl/aux_/config/eti.hpp"
|
||||
|
||||
#include "boost/type_traits/is_same.hpp"
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_VOID_SPEC_PARAM(T)
|
||||
>
|
||||
struct is_sequence
|
||||
: logical_not< is_same< typename begin<T>::type, non_sequence_tag > >
|
||||
{
|
||||
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_sequence,(T))
|
||||
};
|
||||
|
||||
#if defined(BOOST_MPL_MSVC_ETI_BUG)
|
||||
template<> struct is_sequence<int>
|
||||
: bool_c<false>
|
||||
{
|
||||
};
|
||||
#endif
|
||||
|
||||
BOOST_MPL_AUX_VOID_SPEC(1, is_sequence)
|
||||
|
||||
}} // namespace boost::mpl
|
||||
|
||||
#endif // BOOST_MPL_IS_SEQUENCE_HPP_INCLUDED
|
@@ -17,30 +17,86 @@
|
||||
#ifndef BOOST_MPL_SEQUENCE_TAG_HPP_INCLUDED
|
||||
#define BOOST_MPL_SEQUENCE_TAG_HPP_INCLUDED
|
||||
|
||||
#include "boost/mpl/sequence_tag_fwd.hpp"
|
||||
#include "boost/mpl/aux_/has_tag.hpp"
|
||||
#include "boost/mpl/aux_/has_begin.hpp"
|
||||
#include "boost/mpl/aux_/void_spec.hpp"
|
||||
#include "boost/mpl/aux_/config/eti.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace mpl {
|
||||
#include "boost/type_traits/is_class.hpp"
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
namespace aux {
|
||||
|
||||
template< bool has_tag_, bool has_begin_ >
|
||||
struct class_sequence_tag_impl
|
||||
{
|
||||
// agurt 24/nov/02: MSVC 6.5 gets confused in 'sequence_tag_impl<true>'
|
||||
// specialization below, if we name it 'result_' here
|
||||
template< typename Sequence > struct result2_;
|
||||
};
|
||||
|
||||
# define AUX_CLASS_SEQUENCE_TAG_SPEC(has_tag, has_begin, result_type) \
|
||||
template<> struct class_sequence_tag_impl<has_tag,has_begin> \
|
||||
{ \
|
||||
template< typename Sequence > struct result2_ \
|
||||
{ \
|
||||
typedef result_type type; \
|
||||
}; \
|
||||
}; \
|
||||
/**/
|
||||
|
||||
AUX_CLASS_SEQUENCE_TAG_SPEC(true, true, typename Sequence::tag)
|
||||
AUX_CLASS_SEQUENCE_TAG_SPEC(true, false, typename Sequence::tag)
|
||||
AUX_CLASS_SEQUENCE_TAG_SPEC(false, true, nested_begin_end_tag)
|
||||
AUX_CLASS_SEQUENCE_TAG_SPEC(false, false, non_sequence_tag)
|
||||
|
||||
# undef AUX_CLASS_SEQUENCE_TAG_SPEC
|
||||
|
||||
|
||||
template< bool is_class_ >
|
||||
struct sequence_tag_impl
|
||||
{
|
||||
template< typename Sequence > struct result_
|
||||
{
|
||||
typedef non_sequence_tag type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct sequence_tag_impl<true>
|
||||
{
|
||||
template< typename Sequence > struct result_
|
||||
: class_sequence_tag_impl<
|
||||
::boost::mpl::aux::has_tag<Sequence>::value
|
||||
, ::boost::mpl::aux::has_begin<Sequence>::value
|
||||
>::template result2_<Sequence>
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace aux
|
||||
|
||||
template<
|
||||
typename BOOST_MPL_AUX_VOID_SPEC_PARAM(Sequence)
|
||||
>
|
||||
struct sequence_tag
|
||||
: aux::sequence_tag_impl<
|
||||
::boost::is_class<Sequence>::value
|
||||
>::template result_<Sequence>
|
||||
{
|
||||
typedef typename Sequence::tag type;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MPL_MSVC_ETI_BUG)
|
||||
template<> struct sequence_tag<int>
|
||||
{
|
||||
typedef int type;
|
||||
typedef non_sequence_tag type;
|
||||
};
|
||||
#endif
|
||||
|
||||
BOOST_MPL_AUX_VOID_SPEC(1, sequence_tag)
|
||||
|
||||
} // namespace mpl
|
||||
} // namespace boost
|
||||
}} // namespace boost::mpl
|
||||
|
||||
#endif // BOOST_MPL_SEQUENCE_TAG_HPP_INCLUDED
|
||||
|
29
include/boost/mpl/sequence_tag_fwd.hpp
Normal file
29
include/boost/mpl/sequence_tag_fwd.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost mpl/sequence_tag_fwd.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000-02
|
||||
// Aleksey Gurtovoy
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
|
||||
#ifndef BOOST_MPL_SEQUENCE_TAG_FWD_HPP_INCLUDED
|
||||
#define BOOST_MPL_SEQUENCE_TAG_FWD_HPP_INCLUDED
|
||||
|
||||
namespace boost { namespace mpl {
|
||||
|
||||
struct nested_begin_end_tag;
|
||||
struct non_sequence_tag;
|
||||
|
||||
template< typename Sequence > struct sequence_tag;
|
||||
|
||||
}} // namespace boost::mpl
|
||||
|
||||
#endif // BOOST_MPL_SEQUENCE_TAG_FWD_HPP_INCLUDED
|
Reference in New Issue
Block a user