mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-03 14:54:30 +02:00
basic 'set' operations
[SVN r18342]
This commit is contained in:
38
include/boost/mpl/aux_/order_impl.hpp
Normal file
38
include/boost/mpl/aux_/order_impl.hpp
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
#ifndef BOOST_MPL_AUX_ORDER_IMPL_HPP_INCLUDED
|
||||||
|
#define BOOST_MPL_AUX_ORDER_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
|
// + file: boost/mpl/aux_/order_impl.hpp
|
||||||
|
// + last modified: 03/may/03
|
||||||
|
|
||||||
|
// Copyright (c) 2002-03
|
||||||
|
// David Abrahams, 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.
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/mpl for documentation.
|
||||||
|
|
||||||
|
#include "boost/mpl/order_fwd.hpp"
|
||||||
|
#include "boost/mpl/aux_/traits_lambda_spec.hpp"
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace mpl {
|
||||||
|
|
||||||
|
// no default implementation; the definition is needed to make MSVC happy
|
||||||
|
|
||||||
|
template< typename Tag > struct order_impl
|
||||||
|
{
|
||||||
|
template< typename AssociativeSequence, typename Key > struct apply;
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOST_MPL_ALGORITM_TRAITS_LAMBDA_SPEC(2,order_impl)
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif // BOOST_MPL_AUX_ORDER_IMPL_HPP_INCLUDED
|
27
include/boost/mpl/aux_/ptr_to_ref.hpp
Normal file
27
include/boost/mpl/aux_/ptr_to_ref.hpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
#ifndef BOOST_MPL_AUX_PTR_TO_REF_HPP_INCLUDED
|
||||||
|
#define BOOST_MPL_AUX_PTR_TO_REF_HPP_INCLUDED
|
||||||
|
|
||||||
|
// + file: boost/mpl/aux_/ptr_to_ref.hpp
|
||||||
|
// + last modified: 03/may/03
|
||||||
|
|
||||||
|
// Copyright (c) 2002-03
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/mpl for documentation.
|
||||||
|
|
||||||
|
namespace boost { namespace mpl { namespace aux {
|
||||||
|
|
||||||
|
template< typename T > static T const& ptr_to_ref(T*);
|
||||||
|
|
||||||
|
}}}
|
||||||
|
|
||||||
|
#endif // BOOST_MPL_AUX_PTR_TO_REF_HPP_INCLUDED
|
45
include/boost/mpl/order.hpp
Normal file
45
include/boost/mpl/order.hpp
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
|
||||||
|
#ifndef BOOST_MPL_ORDER_HPP_INCLUDED
|
||||||
|
#define BOOST_MPL_ORDER_HPP_INCLUDED
|
||||||
|
|
||||||
|
// + file: boost/mpl/order.hpp
|
||||||
|
// + last modified: 02/may/03
|
||||||
|
|
||||||
|
// Copyright (c) 2002-03
|
||||||
|
// David Abrahams, 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.
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/mpl for documentation.
|
||||||
|
|
||||||
|
#include "boost/mpl/order_fwd.hpp"
|
||||||
|
#include "boost/mpl/aux_/order_impl.hpp"
|
||||||
|
#include "boost/mpl/aux_/sequence_tag.hpp"
|
||||||
|
#include "boost/mpl/aux_/void_spec.hpp"
|
||||||
|
#include "boost/mpl/aux_/lambda_support.hpp"
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace mpl {
|
||||||
|
|
||||||
|
template<
|
||||||
|
typename BOOST_MPL_AUX_VOID_SPEC_PARAM(AssociativeSequence)
|
||||||
|
, typename BOOST_MPL_AUX_VOID_SPEC_PARAM(Key)
|
||||||
|
>
|
||||||
|
struct order
|
||||||
|
: order_impl< typename BOOST_MPL_AUX_SEQUENCE_TAG(AssociativeSequence) >
|
||||||
|
::template apply<AssociativeSequence,Key>
|
||||||
|
{
|
||||||
|
BOOST_MPL_AUX_LAMBDA_SUPPORT(2,order,(AssociativeSequence,Key))
|
||||||
|
};
|
||||||
|
|
||||||
|
BOOST_MPL_AUX_VOID_SPEC(2, order)
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif // BOOST_MPL_ORDER_HPP_INCLUDED
|
29
include/boost/mpl/order_fwd.hpp
Normal file
29
include/boost/mpl/order_fwd.hpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
#ifndef BOOST_MPL_ORDER_FWD_HPP_INCLUDED
|
||||||
|
#define BOOST_MPL_ORDER_FWD_HPP_INCLUDED
|
||||||
|
|
||||||
|
// + file: boost/mpl/order_fwd.hpp
|
||||||
|
// + last modified: 03/may/03
|
||||||
|
|
||||||
|
// Copyright (c) 2002-03
|
||||||
|
// David Abrahams, 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.
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/mpl for documentation.
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace mpl {
|
||||||
|
|
||||||
|
template< typename Tag > struct order_impl;
|
||||||
|
template< typename AssociativeSequence, typename Key > struct order;
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif // BOOST_MPL_ORDER_FWD_HPP_INCLUDED
|
46
include/boost/mpl/set/aux_/begin_end_impl.hpp
Normal file
46
include/boost/mpl/set/aux_/begin_end_impl.hpp
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
#ifndef BOOST_MPL_SET_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|
||||||
|
#define BOOST_MPL_SET_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
|
// + file: boost/mpl/aux_/begin_end_impl.hpp
|
||||||
|
// + last modified: 03/may/03
|
||||||
|
|
||||||
|
// Copyright (c) 2002-03
|
||||||
|
// David Abrahams, 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.
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/mpl for documentation.
|
||||||
|
|
||||||
|
#include "boost/mpl/begin_end_fwd.hpp"
|
||||||
|
#include "boost/mpl/set/aux_/iterator.hpp"
|
||||||
|
|
||||||
|
namespace boost { namespace mpl {
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct begin_traits< aux::set_tag >
|
||||||
|
{
|
||||||
|
template< typename Set > struct algorithm
|
||||||
|
{
|
||||||
|
typedef set_iter<Set,Set> type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct end_traits< aux::set_tag >
|
||||||
|
{
|
||||||
|
template< typename Set > struct algorithm
|
||||||
|
{
|
||||||
|
typedef set_iter< Set,set0<> > type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif // BOOST_MPL_SET_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|
@@ -24,23 +24,40 @@
|
|||||||
#include "boost/mpl/aux_/static_cast.hpp"
|
#include "boost/mpl/aux_/static_cast.hpp"
|
||||||
#include "boost/mpl/aux_/yes_no.hpp"
|
#include "boost/mpl/aux_/yes_no.hpp"
|
||||||
#include "boost/mpl/aux_/type_wrapper.hpp"
|
#include "boost/mpl/aux_/type_wrapper.hpp"
|
||||||
|
#include "boost/mpl/aux_/ptr_to_ref.hpp"
|
||||||
|
#include "boost/mpl/aux_/config/workaround.hpp"
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace mpl {
|
namespace mpl {
|
||||||
|
|
||||||
aux::no_tag has_key_test(...);
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct has_key_impl< aux::set_tag >
|
struct has_key_impl< aux::set_tag >
|
||||||
{
|
{
|
||||||
template< typename Set, typename T > struct apply
|
template< typename Set, typename T > struct apply
|
||||||
|
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561))
|
||||||
|
{
|
||||||
|
BOOST_STATIC_CONSTANT(bool, value =
|
||||||
|
( sizeof(
|
||||||
|
*BOOST_MPL_AUX_STATIC_CAST(Set*, 0)
|
||||||
|
% BOOST_MPL_AUX_STATIC_CAST(aux::type_wrapper<T>*, 0)
|
||||||
|
) == sizeof(aux::yes_tag) )
|
||||||
|
);
|
||||||
|
|
||||||
|
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561))
|
||||||
|
typedef bool_<(apply::value)> type;
|
||||||
|
# else
|
||||||
|
typedef bool_<value> type;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#else
|
||||||
: bool_<
|
: bool_<
|
||||||
( sizeof( has_key_test(
|
( sizeof(
|
||||||
BOOST_MPL_AUX_STATIC_CAST(Set*, 0)
|
aux::ptr_to_ref(BOOST_MPL_AUX_STATIC_CAST(Set*, 0))
|
||||||
, BOOST_MPL_AUX_STATIC_CAST(aux::type_wrapper<T>*, 0)
|
% BOOST_MPL_AUX_STATIC_CAST(aux::type_wrapper<T>*, 0)
|
||||||
) ) == sizeof(aux::yes_tag) )
|
) == sizeof(aux::yes_tag) )
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
100
include/boost/mpl/set/aux_/item.hpp
Normal file
100
include/boost/mpl/set/aux_/item.hpp
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
|
||||||
|
#ifndef BOOST_MPL_SET_AUX_ITEM_HPP_INCLUDED
|
||||||
|
#define BOOST_MPL_SET_AUX_ITEM_HPP_INCLUDED
|
||||||
|
|
||||||
|
// + file: boost/mpl/aux_/item.hpp
|
||||||
|
// + last modified: 03/may/03
|
||||||
|
|
||||||
|
// Copyright (c) 2002-03
|
||||||
|
// David Abrahams, 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.
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/mpl for documentation.
|
||||||
|
|
||||||
|
#include "boost/mpl/long.hpp"
|
||||||
|
#include "boost/mpl/set/aux_/set0.hpp"
|
||||||
|
#include "boost/mpl/aux_/yes_no.hpp"
|
||||||
|
#include "boost/mpl/aux_/type_wrapper.hpp"
|
||||||
|
#include "boost/mpl/aux_/config/static_constant.hpp"
|
||||||
|
#include "boost/mpl/aux_/config/workaround.hpp"
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace mpl {
|
||||||
|
|
||||||
|
aux::no_tag operator/(set0<> const&, void*);
|
||||||
|
aux::no_tag operator%(set0<> const&, void*);
|
||||||
|
|
||||||
|
// agurt, 03/may/03: forward declarations of operators, to supressing a GCC warning,
|
||||||
|
// see below; breaks 2.95.x!
|
||||||
|
#if BOOST_WORKAROUND(__GNUC__, > 2) && BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(3))
|
||||||
|
template< typename T, typename Base > struct s_item;
|
||||||
|
template< typename T, typename Base > struct s_mask;
|
||||||
|
|
||||||
|
template< typename T, typename Base >
|
||||||
|
typename s_item<T,Base>::order_tag
|
||||||
|
operator/(s_item<T,Base> const&, aux::type_wrapper<T>*);
|
||||||
|
|
||||||
|
template< typename T, typename Base >
|
||||||
|
aux::yes_tag operator%(s_item<T,Base> const&, aux::type_wrapper<T>*);
|
||||||
|
|
||||||
|
template< typename T, typename Base >
|
||||||
|
aux::no_tag operator%(s_mask<T,Base> const&, aux::type_wrapper<T>*);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561))
|
||||||
|
namespace aux {
|
||||||
|
template< long n_ > struct order_tag_
|
||||||
|
{
|
||||||
|
typedef char (&type)[n_];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template< typename T, typename Base >
|
||||||
|
struct s_item
|
||||||
|
: Base
|
||||||
|
{
|
||||||
|
typedef T item;
|
||||||
|
typedef Base base;
|
||||||
|
|
||||||
|
BOOST_STATIC_CONSTANT(long, order = Base::order + 1);
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561))
|
||||||
|
typedef typename aux::order_tag_<(Base::order + 1)>::type order_tag;
|
||||||
|
#else
|
||||||
|
typedef char (&order_tag)[order];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(__GNUC__, > 2) && BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(3))
|
||||||
|
// to make GCC happy
|
||||||
|
friend order_tag operator/<>(s_item const&, aux::type_wrapper<T>*);
|
||||||
|
friend aux::yes_tag operator%<>(s_item const&, aux::type_wrapper<T>*);
|
||||||
|
#else
|
||||||
|
friend order_tag operator/(s_item const&, aux::type_wrapper<T>*);
|
||||||
|
friend aux::yes_tag operator%(s_item const&, aux::type_wrapper<T>*);
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template< typename T, typename Base >
|
||||||
|
struct s_mask
|
||||||
|
: Base
|
||||||
|
{
|
||||||
|
#if BOOST_WORKAROUND(__GNUC__, > 2) && BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(3))
|
||||||
|
// to make GCC happy
|
||||||
|
friend aux::no_tag operator%<>(s_mask const&, aux::type_wrapper<T>*);
|
||||||
|
#else
|
||||||
|
friend aux::no_tag operator%(s_mask const&, aux::type_wrapper<T>*);
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif // BOOST_MPL_SET_AUX_ITEM_HPP_INCLUDED
|
83
include/boost/mpl/set/aux_/iterator.hpp
Normal file
83
include/boost/mpl/set/aux_/iterator.hpp
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
|
||||||
|
#ifndef BOOST_MPL_SET_AUX_ITERATOR_HPP_INCLUDED
|
||||||
|
#define BOOST_MPL_SET_AUX_ITERATOR_HPP_INCLUDED
|
||||||
|
|
||||||
|
// + file: boost/mpl/aux_/iterator.hpp
|
||||||
|
// + last modified: 03/may/03
|
||||||
|
|
||||||
|
// Copyright (c) 2002-03
|
||||||
|
// David Abrahams, 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.
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/mpl for documentation.
|
||||||
|
|
||||||
|
#include "boost/mpl/set/aux_/set0.hpp"
|
||||||
|
#include "boost/mpl/has_key.hpp"
|
||||||
|
#include "boost/mpl/iterator_tag.hpp"
|
||||||
|
#include "boost/mpl/next.hpp"
|
||||||
|
#include "boost/mpl/apply_if.hpp"
|
||||||
|
#include "boost/mpl/if.hpp"
|
||||||
|
#include "boost/mpl/identity.hpp"
|
||||||
|
#include "boost/mpl/aux_/config/ctps.hpp"
|
||||||
|
|
||||||
|
namespace boost { namespace mpl {
|
||||||
|
|
||||||
|
// used by 'set_iter_impl'
|
||||||
|
template< typename Set, typename Tail > struct set_iter;
|
||||||
|
|
||||||
|
template< typename Set, typename Tail > struct set_iter_impl
|
||||||
|
{
|
||||||
|
typedef Tail tail_;
|
||||||
|
typedef fwd_iter_tag_ category;
|
||||||
|
typedef typename Tail::item type;
|
||||||
|
|
||||||
|
typedef typename apply_if<
|
||||||
|
has_key< Set,typename Tail::base::item >
|
||||||
|
, identity< set_iter<Set,typename Tail::base> >
|
||||||
|
, next< set_iter<Set,typename Tail::base> >
|
||||||
|
>::type next;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||||
|
|
||||||
|
template< typename Set >
|
||||||
|
struct set_end_iter
|
||||||
|
{
|
||||||
|
typedef fwd_iter_tag_ category;
|
||||||
|
typedef set_iter<Set,set0<> > next;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename Set, typename Tail > struct set_iter
|
||||||
|
: if_<
|
||||||
|
is_same< Tail,set0<> >
|
||||||
|
, set_end_iter<Set>
|
||||||
|
, set_iter_impl<Set,Tail>
|
||||||
|
>::type
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
template< typename Set, typename Tail > struct set_iter
|
||||||
|
: set_iter_impl<Set,Tail>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename Set > struct set_iter<Set, set0<> >
|
||||||
|
{
|
||||||
|
typedef fwd_iter_tag_ category;
|
||||||
|
typedef set_iter next;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif // BOOST_MPL_SET_AUX_ITERATOR_HPP_INCLUDED
|
74
include/boost/mpl/set/aux_/order_impl.hpp
Normal file
74
include/boost/mpl/set/aux_/order_impl.hpp
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
|
||||||
|
#ifndef BOOST_MPL_SET_AUX_ORDER_IMPL_HPP_INCLUDED
|
||||||
|
#define BOOST_MPL_SET_AUX_ORDER_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
|
// + file: boost/mpl/aux_/item.hpp
|
||||||
|
// + last modified: 03/may/03
|
||||||
|
|
||||||
|
// Copyright (c) 2002-03
|
||||||
|
// David Abrahams, 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.
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/mpl for documentation.
|
||||||
|
|
||||||
|
#include "boost/mpl/set/aux_/tag.hpp"
|
||||||
|
#include "boost/mpl/order_fwd.hpp"
|
||||||
|
#include "boost/mpl/long.hpp"
|
||||||
|
#include "boost/mpl/void.hpp"
|
||||||
|
#include "boost/mpl/aux_/static_cast.hpp"
|
||||||
|
#include "boost/mpl/aux_/type_wrapper.hpp"
|
||||||
|
#include "boost/mpl/aux_/ptr_to_ref.hpp"
|
||||||
|
#include "boost/mpl/aux_/config/static_constant.hpp"
|
||||||
|
#include "boost/mpl/aux_/config/workaround.hpp"
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
|
namespace mpl {
|
||||||
|
|
||||||
|
namespace aux {
|
||||||
|
template< long n_ > struct long_or_void : long_<n_> {};
|
||||||
|
template<> struct long_or_void<0> : void_ {};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct order_impl< aux::set_tag >
|
||||||
|
{
|
||||||
|
|
||||||
|
template< typename Set, typename T > struct apply
|
||||||
|
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561))
|
||||||
|
{
|
||||||
|
BOOST_STATIC_CONSTANT(long, value =
|
||||||
|
sizeof(
|
||||||
|
*BOOST_MPL_AUX_STATIC_CAST(Set*, 0)
|
||||||
|
/ BOOST_MPL_AUX_STATIC_CAST(aux::type_wrapper<T>*, 0)
|
||||||
|
) - 1
|
||||||
|
);
|
||||||
|
|
||||||
|
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x561))
|
||||||
|
typedef typename aux::long_or_void<(apply::value)>::type type;
|
||||||
|
# else
|
||||||
|
typedef typename aux::long_or_void<value>::type type;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
: aux::long_or_void<
|
||||||
|
sizeof(
|
||||||
|
aux::ptr_to_ref(BOOST_MPL_AUX_STATIC_CAST(Set*, 0))
|
||||||
|
/ BOOST_MPL_AUX_STATIC_CAST(aux::type_wrapper<T>*, 0)
|
||||||
|
) - 1
|
||||||
|
>
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
#endif // BOOST_MPL_SET_AUX_ORDER_IMPL_HPP_INCLUDED
|
@@ -3,7 +3,7 @@
|
|||||||
#define BOOST_MPL_SET_AUX_SET0_HPP_INCLUDED
|
#define BOOST_MPL_SET_AUX_SET0_HPP_INCLUDED
|
||||||
|
|
||||||
// + file: boost/mpl/aux_/set0.hpp
|
// + file: boost/mpl/aux_/set0.hpp
|
||||||
// + last modified: 02/may/03
|
// + last modified: 03/may/03
|
||||||
|
|
||||||
// Copyright (c) 2002-03
|
// Copyright (c) 2002-03
|
||||||
// David Abrahams, Aleksey Gurtovoy
|
// David Abrahams, Aleksey Gurtovoy
|
||||||
@@ -20,13 +20,16 @@
|
|||||||
|
|
||||||
#include "boost/mpl/void.hpp"
|
#include "boost/mpl/void.hpp"
|
||||||
#include "boost/mpl/set/aux_/tag.hpp"
|
#include "boost/mpl/set/aux_/tag.hpp"
|
||||||
|
#include "boost/mpl/aux_/config/static_constant.hpp"
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace mpl {
|
namespace mpl {
|
||||||
|
|
||||||
template< typename D_ = void_ > struct set0
|
template< int p_ = 0 > struct set0
|
||||||
{
|
{
|
||||||
typedef aux::set_tag tag;
|
typedef aux::set_tag tag;
|
||||||
|
typedef void_ item;
|
||||||
|
BOOST_STATIC_CONSTANT(long, order = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
@@ -27,11 +27,12 @@
|
|||||||
//#include "boost/mpl/set/aux_/O1_size.hpp"
|
//#include "boost/mpl/set/aux_/O1_size.hpp"
|
||||||
//#include "boost/mpl/set/aux_/size.hpp"
|
//#include "boost/mpl/set/aux_/size.hpp"
|
||||||
//#include "boost/mpl/set/aux_/empty.hpp"
|
//#include "boost/mpl/set/aux_/empty.hpp"
|
||||||
//#include "boost/mpl/set/aux_/item.hpp"
|
#include "boost/mpl/set/aux_/order_impl.hpp"
|
||||||
//#include "boost/mpl/set/aux_/iterator.hpp"
|
|
||||||
#include "boost/mpl/set/aux_/has_key_impl.hpp"
|
#include "boost/mpl/set/aux_/has_key_impl.hpp"
|
||||||
|
#include "boost/mpl/set/aux_/begin_end_impl.hpp"
|
||||||
|
#include "boost/mpl/set/aux_/iterator.hpp"
|
||||||
|
#include "boost/mpl/set/aux_/item.hpp"
|
||||||
#include "boost/mpl/set/aux_/set0.hpp"
|
#include "boost/mpl/set/aux_/set0.hpp"
|
||||||
//#include "boost/mpl/set/aux_/begin_end.hpp"
|
#include "boost/mpl/set/aux_/tag.hpp"
|
||||||
//#include "boost/mpl/set/aux_/tag.hpp"
|
|
||||||
|
|
||||||
#endif // BOOST_MPL_SET_SET0_HPP_INCLUDED
|
#endif // BOOST_MPL_SET_SET0_HPP_INCLUDED
|
||||||
|
@@ -27,7 +27,7 @@ namespace mpl {
|
|||||||
// instantiated so that it can be passed in as an object that can be
|
// instantiated so that it can be passed in as an object that can be
|
||||||
// used to select an overloaded function. Possible use includes signaling
|
// used to select an overloaded function. Possible use includes signaling
|
||||||
// a zero arity functor evaluation call.
|
// a zero arity functor evaluation call.
|
||||||
struct void_ {};
|
struct void_ { typedef void_ type; };
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
struct is_void_
|
struct is_void_
|
||||||
|
59
test/set.cpp
59
test/set.cpp
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// + file: libs/mpl/test/set.cpp
|
// + file: libs/mpl/test/set.cpp
|
||||||
// + last modified: 02/may/03
|
// + last modified: 03/may/03
|
||||||
|
|
||||||
// Copyright (c) 2002-03
|
// Copyright (c) 2002-03
|
||||||
// Aleksey Gurtovoy
|
// Aleksey Gurtovoy
|
||||||
@@ -17,9 +17,14 @@
|
|||||||
|
|
||||||
#include "boost/mpl/set/set0.hpp"
|
#include "boost/mpl/set/set0.hpp"
|
||||||
#include "boost/mpl/has_key.hpp"
|
#include "boost/mpl/has_key.hpp"
|
||||||
|
#include "boost/mpl/order.hpp"
|
||||||
|
#include "boost/mpl/begin_end.hpp"
|
||||||
|
|
||||||
|
#include "boost/type_traits/is_same.hpp"
|
||||||
#include "boost/static_assert.hpp"
|
#include "boost/static_assert.hpp"
|
||||||
|
|
||||||
namespace mpl = boost::mpl;
|
using namespace boost::mpl;
|
||||||
|
using namespace boost;
|
||||||
|
|
||||||
#define MPL_TEST_CASE( test_name ) void test_name()
|
#define MPL_TEST_CASE( test_name ) void test_name()
|
||||||
#define MPL_TEST_ASSERT( expr ) BOOST_STATIC_ASSERT( expr )
|
#define MPL_TEST_ASSERT( expr ) BOOST_STATIC_ASSERT( expr )
|
||||||
@@ -27,30 +32,46 @@ namespace mpl = boost::mpl;
|
|||||||
struct UDT {};
|
struct UDT {};
|
||||||
struct incomplete;
|
struct incomplete;
|
||||||
|
|
||||||
MPL_TEST_CASE( empty_set )
|
MPL_TEST_CASE( has_key_test2 )
|
||||||
{
|
{
|
||||||
typedef mpl::set0<> s;
|
typedef s_mask<char,s_item<int,s_item<char, set0<> > > > s;
|
||||||
|
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,char>::type::value ));
|
MPL_TEST_ASSERT(( !has_key<s,char>::type::value ));
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,int>::type::value ));
|
MPL_TEST_ASSERT(( has_key<s,int>::type::value ));
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,UDT>::type::value ));
|
MPL_TEST_ASSERT(( order<s,int>::type::value == 1 ));
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,incomplete>::type::value ));
|
MPL_TEST_ASSERT(( is_same< order<s,char>::type,void_ >::value ));
|
||||||
|
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,char const>::type::value ));
|
typedef begin<s>::type first;
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,int const>::type::value ));
|
typedef end<s>::type last;
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,UDT const>::type::value ));
|
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,incomplete const>::type::value ));
|
|
||||||
|
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,int*>::type::value ));
|
MPL_TEST_ASSERT(( is_same<first::type,int>::value ));
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,UDT*>::type::value ));
|
MPL_TEST_ASSERT(( is_same<first::next,last>::value ));
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,incomplete*>::type::value ));
|
|
||||||
|
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,int&>::type::value ));
|
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,UDT&>::type::value ));
|
|
||||||
MPL_TEST_ASSERT(( !mpl::has_key<s,incomplete&>::type::value ));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MPL_TEST_CASE( empty_set_test )
|
||||||
|
{
|
||||||
|
typedef set0<> s;
|
||||||
|
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,char>::type::value ));
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,int>::type::value ));
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,UDT>::type::value ));
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,incomplete>::type::value ));
|
||||||
|
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,char const>::type::value ));
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,int const>::type::value ));
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,UDT const>::type::value ));
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,incomplete const>::type::value ));
|
||||||
|
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,int*>::type::value ));
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,UDT*>::type::value ));
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,incomplete*>::type::value ));
|
||||||
|
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,int&>::type::value ));
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,UDT&>::type::value ));
|
||||||
|
MPL_TEST_ASSERT(( !has_key<s,incomplete&>::type::value ));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user