mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-05 07:44:32 +02:00
'set' fixes + more thorough regression tests
[SVN r37335]
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
#ifndef BOOST_MPL_SET_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|
#ifndef BOOST_MPL_SET_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|
||||||
#define BOOST_MPL_SET_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|
#define BOOST_MPL_SET_AUX_BEGIN_END_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
// Copyright Aleksey Gurtovoy 2003-2004
|
// Copyright Aleksey Gurtovoy 2003-2007
|
||||||
// Copyright David Abrahams 2003-2004
|
// Copyright David Abrahams 2003-2004
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
@@ -24,8 +24,8 @@ template<>
|
|||||||
struct begin_impl< aux::set_tag >
|
struct begin_impl< aux::set_tag >
|
||||||
{
|
{
|
||||||
template< typename Set > struct apply
|
template< typename Set > struct apply
|
||||||
|
: s_iter_get<Set,typename Set::item_>
|
||||||
{
|
{
|
||||||
typedef s_iter<Set,Set> type;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#ifndef BOOST_MPL_SET_AUX_ERASE_KEY_IMPL_HPP_INCLUDED
|
#ifndef BOOST_MPL_SET_AUX_ERASE_KEY_IMPL_HPP_INCLUDED
|
||||||
#define BOOST_MPL_SET_AUX_ERASE_KEY_IMPL_HPP_INCLUDED
|
#define BOOST_MPL_SET_AUX_ERASE_KEY_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
// Copyright Aleksey Gurtovoy 2003-2004
|
// Copyright Aleksey Gurtovoy 2003-2007
|
||||||
// Copyright David Abrahams 2003-2004
|
// Copyright David Abrahams 2003-2004
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
@@ -40,7 +40,7 @@ struct erase_key_impl< aux::set_tag >
|
|||||||
, eval_if<
|
, eval_if<
|
||||||
is_same< T,typename Set::item_type_ >
|
is_same< T,typename Set::item_type_ >
|
||||||
, base<Set>
|
, base<Set>
|
||||||
, identity< s_mask<T,Set> >
|
, identity< s_mask<T,typename Set::item_> >
|
||||||
>
|
>
|
||||||
, identity<Set>
|
, identity<Set>
|
||||||
>
|
>
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#ifndef BOOST_MPL_SET_AUX_INSERT_IMPL_HPP_INCLUDED
|
#ifndef BOOST_MPL_SET_AUX_INSERT_IMPL_HPP_INCLUDED
|
||||||
#define BOOST_MPL_SET_AUX_INSERT_IMPL_HPP_INCLUDED
|
#define BOOST_MPL_SET_AUX_INSERT_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
// Copyright Aleksey Gurtovoy 2003-2004
|
// Copyright Aleksey Gurtovoy 2003-2007
|
||||||
// Copyright David Abrahams 2003-2004
|
// Copyright David Abrahams 2003-2004
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
@@ -36,7 +36,7 @@ template< typename Set, typename T > struct set_insert_impl
|
|||||||
, eval_if<
|
, eval_if<
|
||||||
is_same< T,typename Set::last_masked_ >
|
is_same< T,typename Set::last_masked_ >
|
||||||
, base<Set>
|
, base<Set>
|
||||||
, identity< s_item<T,Set> >
|
, identity< s_item<T,typename Set::item_> >
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#ifndef BOOST_MPL_SET_AUX_ITEM_HPP_INCLUDED
|
#ifndef BOOST_MPL_SET_AUX_ITEM_HPP_INCLUDED
|
||||||
#define BOOST_MPL_SET_AUX_ITEM_HPP_INCLUDED
|
#define BOOST_MPL_SET_AUX_ITEM_HPP_INCLUDED
|
||||||
|
|
||||||
// Copyright Aleksey Gurtovoy 2003-2004
|
// Copyright Aleksey Gurtovoy 2003-2007
|
||||||
// Copyright David Abrahams 2003-2004
|
// Copyright David Abrahams 2003-2004
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
@@ -31,9 +31,7 @@ struct s_item
|
|||||||
{
|
{
|
||||||
typedef s_item<T,Base> item_;
|
typedef s_item<T,Base> item_;
|
||||||
typedef void_ last_masked_;
|
typedef void_ last_masked_;
|
||||||
typedef Base next_;
|
|
||||||
typedef T item_type_;
|
typedef T item_type_;
|
||||||
typedef item_type_ type;
|
|
||||||
typedef Base base;
|
typedef Base base;
|
||||||
|
|
||||||
typedef typename next< typename Base::size >::type size;
|
typedef typename next< typename Base::size >::type size;
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
#ifndef BOOST_MPL_SET_AUX_ITERATOR_HPP_INCLUDED
|
#ifndef BOOST_MPL_SET_AUX_ITERATOR_HPP_INCLUDED
|
||||||
#define BOOST_MPL_SET_AUX_ITERATOR_HPP_INCLUDED
|
#define BOOST_MPL_SET_AUX_ITERATOR_HPP_INCLUDED
|
||||||
|
|
||||||
// Copyright Aleksey Gurtovoy 2003-2004
|
// Copyright Aleksey Gurtovoy 2003-2007
|
||||||
// Copyright David Abrahams 2003-2004
|
// Copyright David Abrahams 2003-2004
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
@@ -26,21 +26,26 @@
|
|||||||
|
|
||||||
namespace boost { namespace mpl {
|
namespace boost { namespace mpl {
|
||||||
|
|
||||||
// used by 's_iter_impl'
|
// used by 's_iter_get'
|
||||||
template< typename Set, typename Tail > struct s_iter;
|
template< typename Set, typename Tail > struct s_iter;
|
||||||
|
|
||||||
|
template< typename Set, typename Tail > struct s_iter_get
|
||||||
|
: eval_if<
|
||||||
|
has_key< Set,typename Tail::item_type_ >
|
||||||
|
, identity< s_iter<Set,Tail> >
|
||||||
|
, next< s_iter<Set,Tail> >
|
||||||
|
>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
template< typename Set, typename Tail > struct s_iter_impl
|
template< typename Set, typename Tail > struct s_iter_impl
|
||||||
{
|
{
|
||||||
typedef Tail tail_;
|
typedef Tail tail_;
|
||||||
typedef forward_iterator_tag category;
|
typedef forward_iterator_tag category;
|
||||||
typedef typename Tail::item_::type type;
|
typedef typename Tail::item_type_ type;
|
||||||
|
|
||||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||||
typedef typename eval_if<
|
typedef typename s_iter_get< Set,typename Tail::base >::type next;
|
||||||
has_key< Set,typename Tail::next_::type >
|
|
||||||
, identity< s_iter<Set,typename Tail::next_> >
|
|
||||||
, next< s_iter<Set,typename Tail::next_> >
|
|
||||||
>::type next;
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,11 +53,7 @@ template< typename Set, typename Tail > struct s_iter_impl
|
|||||||
|
|
||||||
template< typename Set, typename Tail >
|
template< typename Set, typename Tail >
|
||||||
struct next< s_iter<Set,Tail> >
|
struct next< s_iter<Set,Tail> >
|
||||||
: eval_if<
|
: s_iter_get< Set,typename Tail::base >
|
||||||
has_key< Set,typename Tail::next_::type >
|
|
||||||
, identity< s_iter<Set,typename Tail::next_> >
|
|
||||||
, next< s_iter<Set,typename Tail::next_> >
|
|
||||||
>
|
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -53,10 +53,10 @@ namespace boost { namespace mpl {
|
|||||||
template< typename Dummy = na > struct set0
|
template< typename Dummy = na > struct set0
|
||||||
{
|
{
|
||||||
typedef set0<> item_;
|
typedef set0<> item_;
|
||||||
|
typedef item_ type;
|
||||||
typedef aux::set_tag tag;
|
typedef aux::set_tag tag;
|
||||||
typedef void_ last_masked_;
|
typedef void_ last_masked_;
|
||||||
typedef void_ item_type_;
|
typedef void_ item_type_;
|
||||||
typedef item_type_ type;
|
|
||||||
typedef long_<0> size;
|
typedef long_<0> size;
|
||||||
typedef long_<1> order;
|
typedef long_<1> order;
|
||||||
|
|
||||||
|
305
test/set.cpp
305
test/set.cpp
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
// Copyright Aleksey Gurtovoy 2003-2004
|
// Copyright Aleksey Gurtovoy 2003-2007
|
||||||
// Copyright David Abrahams 2003-2004
|
// Copyright David Abrahams 2003-2004
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
@@ -13,6 +13,8 @@
|
|||||||
// $Revision$
|
// $Revision$
|
||||||
|
|
||||||
#include <boost/mpl/set.hpp>
|
#include <boost/mpl/set.hpp>
|
||||||
|
#include <boost/mpl/contains.hpp>
|
||||||
|
#include <boost/mpl/find.hpp>
|
||||||
#include <boost/mpl/deref.hpp>
|
#include <boost/mpl/deref.hpp>
|
||||||
#include <boost/mpl/next.hpp>
|
#include <boost/mpl/next.hpp>
|
||||||
#include <boost/mpl/insert.hpp>
|
#include <boost/mpl/insert.hpp>
|
||||||
@@ -23,89 +25,233 @@
|
|||||||
#include <boost/mpl/has_key.hpp>
|
#include <boost/mpl/has_key.hpp>
|
||||||
#include <boost/mpl/order.hpp>
|
#include <boost/mpl/order.hpp>
|
||||||
#include <boost/mpl/size.hpp>
|
#include <boost/mpl/size.hpp>
|
||||||
|
#include <boost/mpl/distance.hpp>
|
||||||
#include <boost/mpl/empty.hpp>
|
#include <boost/mpl/empty.hpp>
|
||||||
#include <boost/mpl/begin_end.hpp>
|
#include <boost/mpl/begin_end.hpp>
|
||||||
#include <boost/mpl/find.hpp>
|
|
||||||
|
|
||||||
#include <boost/mpl/aux_/test.hpp>
|
#include <boost/mpl/aux_/test.hpp>
|
||||||
|
|
||||||
|
|
||||||
MPL_TEST_CASE()
|
// Use templates for testing so that GCC will show us the actual types involved
|
||||||
{
|
|
||||||
typedef s_mask<char,s_item<int,s_item<char, set0<> > > > s;
|
|
||||||
|
|
||||||
|
template< typename s >
|
||||||
|
void empty_set_test()
|
||||||
|
{
|
||||||
|
MPL_ASSERT_RELATION( size<s>::value, ==, 0 );
|
||||||
|
MPL_ASSERT(( empty<s> ));
|
||||||
|
|
||||||
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear<s>::type, set0<> > ));
|
||||||
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,int>::type, void_ > ));
|
||||||
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,char>::type, void_ > ));
|
||||||
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,long>::type, void_ > ));
|
||||||
|
|
||||||
|
MPL_ASSERT_NOT(( has_key<s,int> ));
|
||||||
|
MPL_ASSERT_NOT(( has_key<s,char> ));
|
||||||
|
MPL_ASSERT_NOT(( has_key<s,long> ));
|
||||||
|
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME order<s,int>::type o1;
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME order<s,char>::type o2;
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME order<s,long>::type o3;
|
||||||
|
MPL_ASSERT(( is_same< o1, void_ > ));
|
||||||
|
MPL_ASSERT(( is_same< o2, void_ > ));
|
||||||
|
MPL_ASSERT(( is_same< o3, void_ > ));
|
||||||
|
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME begin<s>::type first;
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME end<s>::type last;
|
||||||
|
|
||||||
|
MPL_ASSERT(( is_same<first, last> ));
|
||||||
|
MPL_ASSERT_RELATION( (distance<first, last>::value), ==, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template< typename s >
|
||||||
|
void int_set_test()
|
||||||
|
{
|
||||||
MPL_ASSERT_RELATION( size<s>::value, ==, 1 );
|
MPL_ASSERT_RELATION( size<s>::value, ==, 1 );
|
||||||
MPL_ASSERT_NOT(( empty<s> ));
|
MPL_ASSERT_NOT(( empty<s> ));
|
||||||
|
|
||||||
MPL_ASSERT(( is_same< clear<s>::type, set0<> > ));
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear<s>::type, set0<> > ));
|
||||||
MPL_ASSERT(( is_same< at<s,int>::type, int > ));
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,int>::type, int > ));
|
||||||
MPL_ASSERT(( is_same< at<s,char>::type, void_ > ));
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,char>::type, void_ > ));
|
||||||
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,long>::type, void_ > ));
|
||||||
|
|
||||||
MPL_ASSERT_NOT(( has_key<s,char> ));
|
|
||||||
MPL_ASSERT(( has_key<s,int> ));
|
MPL_ASSERT(( has_key<s,int> ));
|
||||||
MPL_ASSERT_RELATION( (order<s,int>::value), ==, 3 );
|
MPL_ASSERT_NOT(( has_key<s,char> ));
|
||||||
MPL_ASSERT(( is_same< order<s,char>::type, void_ > ));
|
MPL_ASSERT_NOT(( has_key<s,long> ));
|
||||||
|
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME order<s,int>::type o1;
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME order<s,char>::type o2;
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME order<s,long>::type o3;
|
||||||
|
MPL_ASSERT_NOT(( is_same< o1, void_ > ));
|
||||||
|
MPL_ASSERT(( is_same< o2, void_ > ));
|
||||||
|
MPL_ASSERT(( is_same< o3, void_ > ));
|
||||||
|
|
||||||
typedef begin<s>::type first;
|
typedef BOOST_DEDUCED_TYPENAME begin<s>::type first;
|
||||||
typedef end<s>::type last;
|
typedef BOOST_DEDUCED_TYPENAME end<s>::type last;
|
||||||
|
|
||||||
MPL_ASSERT(( is_same< deref<first>::type, int > ));
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME deref<first>::type, int > ));
|
||||||
MPL_ASSERT(( is_same< next<first>::type, last > ));
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME next<first>::type, last > ));
|
||||||
|
|
||||||
typedef s_unmask<char,s> s2;
|
MPL_ASSERT_RELATION( (distance<first, last>::value), ==, 1 );
|
||||||
|
MPL_ASSERT(( contains< s, int > ));
|
||||||
|
}
|
||||||
|
|
||||||
MPL_ASSERT_RELATION( size<s2>::value, ==, 2 );
|
|
||||||
MPL_ASSERT_NOT(( empty<s2> ));
|
|
||||||
MPL_ASSERT(( is_same<clear<s2>::type, set0<> > ));
|
|
||||||
MPL_ASSERT(( is_same<at<s2,int>::type, int > ));
|
|
||||||
MPL_ASSERT(( is_same<at<s2,char>::type, char > ));
|
|
||||||
|
|
||||||
MPL_ASSERT(( has_key<s2,char> ));
|
template< typename s >
|
||||||
MPL_ASSERT_NOT(( has_key<s2,long> ));
|
void int_char_set_test()
|
||||||
MPL_ASSERT_RELATION( (order<s2,int>::value), ==, 3 );
|
{
|
||||||
MPL_ASSERT_RELATION( (order<s2,char>::value), ==, 2 );
|
MPL_ASSERT_RELATION( size<s>::value, ==, 2 );
|
||||||
|
MPL_ASSERT_NOT(( empty<s> ));
|
||||||
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear<s>::type, set0<> > ));
|
||||||
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,int>::type, int > ));
|
||||||
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,char>::type, char > ));
|
||||||
|
|
||||||
typedef begin<s2>::type first2;
|
MPL_ASSERT(( has_key<s,char> ));
|
||||||
typedef end<s2>::type last2;
|
MPL_ASSERT_NOT(( has_key<s,long> ));
|
||||||
|
|
||||||
MPL_ASSERT(( is_same< deref<first2>::type, int > ));
|
typedef BOOST_DEDUCED_TYPENAME order<s,int>::type o1;
|
||||||
typedef next<first2>::type iter;
|
typedef BOOST_DEDUCED_TYPENAME order<s,char>::type o2;
|
||||||
MPL_ASSERT(( is_same< deref<iter>::type, char > ));
|
typedef BOOST_DEDUCED_TYPENAME order<s,long>::type o3;
|
||||||
MPL_ASSERT(( is_same< next<iter>::type, last2 > ));
|
MPL_ASSERT_NOT(( is_same< o1, void_ > ));
|
||||||
|
MPL_ASSERT_NOT(( is_same< o2, void_ > ));
|
||||||
|
MPL_ASSERT(( is_same< o3, void_ > ));
|
||||||
|
MPL_ASSERT_NOT(( is_same< o1, o2 > ));
|
||||||
|
|
||||||
typedef insert<s2,int>::type s2_1;
|
typedef BOOST_DEDUCED_TYPENAME begin<s>::type first;
|
||||||
MPL_ASSERT(( is_same<s2, s2_1> ));
|
typedef BOOST_DEDUCED_TYPENAME end<s>::type last;
|
||||||
|
|
||||||
typedef insert<s2,long>::type s3;
|
MPL_ASSERT_RELATION( (distance<first, last>::value), ==, 2 );
|
||||||
MPL_ASSERT_RELATION( size<s3>::value, ==, 3 );
|
|
||||||
MPL_ASSERT(( has_key<s3,long> ));
|
|
||||||
MPL_ASSERT(( has_key<s3,int> ));
|
|
||||||
MPL_ASSERT(( has_key<s3,char> ));
|
|
||||||
|
|
||||||
typedef insert<s,char>::type s1;
|
MPL_ASSERT(( contains< s, int > ));
|
||||||
MPL_ASSERT_RELATION( size<s1>::value, ==, 2 );
|
MPL_ASSERT(( contains< s, char > ));
|
||||||
MPL_ASSERT(( is_same<at<s1,int>::type, int > ));
|
}
|
||||||
MPL_ASSERT(( is_same<at<s1,char>::type, char > ));
|
|
||||||
MPL_ASSERT_NOT(( is_same<s1, s2> ));
|
|
||||||
|
|
||||||
typedef erase_key<s1,char>::type s_1;
|
template< typename s >
|
||||||
MPL_ASSERT(( is_same<s, s_1> ));
|
void int_char_long_set_test()
|
||||||
MPL_ASSERT_RELATION( size<s_1>::value, ==, 1 );
|
{
|
||||||
MPL_ASSERT(( is_same< at<s_1,char>::type, void_ > ));
|
MPL_ASSERT_RELATION( size<s>::value, ==, 3 );
|
||||||
MPL_ASSERT(( is_same< at<s_1,int>::type, int > ));
|
MPL_ASSERT_NOT(( empty<s> ));
|
||||||
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear<s>::type, set0<> > ));
|
||||||
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,int>::type, int > ));
|
||||||
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,char>::type, char > ));
|
||||||
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,long>::type, long > ));
|
||||||
|
|
||||||
|
MPL_ASSERT(( has_key<s,long> ));
|
||||||
|
MPL_ASSERT(( has_key<s,int> ));
|
||||||
|
MPL_ASSERT(( has_key<s,char> ));
|
||||||
|
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME order<s,int>::type o1;
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME order<s,char>::type o2;
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME order<s,long>::type o3;
|
||||||
|
MPL_ASSERT_NOT(( is_same< o1, void_ > ));
|
||||||
|
MPL_ASSERT_NOT(( is_same< o2, void_ > ));
|
||||||
|
MPL_ASSERT_NOT(( is_same< o3, void_ > ));
|
||||||
|
MPL_ASSERT_NOT(( is_same< o1, o2 > ));
|
||||||
|
MPL_ASSERT_NOT(( is_same< o1, o3 > ));
|
||||||
|
MPL_ASSERT_NOT(( is_same< o2, o3 > ));
|
||||||
|
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME begin<s>::type first;
|
||||||
|
typedef BOOST_DEDUCED_TYPENAME end<s>::type last;
|
||||||
|
MPL_ASSERT_RELATION( (distance<first, last>::value), ==, 3 );
|
||||||
|
|
||||||
|
MPL_ASSERT(( contains< s, int > ));
|
||||||
|
MPL_ASSERT(( contains< s, char > ));
|
||||||
|
MPL_ASSERT(( contains< s, long > ));
|
||||||
|
}
|
||||||
|
|
||||||
|
template< typename S0, typename S1, typename S2, typename S3 >
|
||||||
|
void basic_set_test()
|
||||||
|
{
|
||||||
|
empty_set_test<S0>();
|
||||||
|
empty_set_test< BOOST_DEDUCED_TYPENAME erase_key<S1,int>::type >();
|
||||||
|
empty_set_test< BOOST_DEDUCED_TYPENAME erase_key<
|
||||||
|
BOOST_DEDUCED_TYPENAME erase_key<S2,char>::type
|
||||||
|
, int
|
||||||
|
>::type >();
|
||||||
|
|
||||||
|
empty_set_test< BOOST_DEDUCED_TYPENAME erase_key<
|
||||||
|
BOOST_DEDUCED_TYPENAME erase_key<
|
||||||
|
BOOST_DEDUCED_TYPENAME erase_key<S3,char>::type
|
||||||
|
, long
|
||||||
|
>::type
|
||||||
|
, int
|
||||||
|
>::type >();
|
||||||
|
|
||||||
|
|
||||||
|
int_set_test<S1>();
|
||||||
|
int_set_test< BOOST_DEDUCED_TYPENAME insert<S0,int>::type >();
|
||||||
|
|
||||||
|
int_set_test< BOOST_DEDUCED_TYPENAME erase_key<S2,char>::type >();
|
||||||
|
int_set_test< BOOST_DEDUCED_TYPENAME erase_key<
|
||||||
|
BOOST_DEDUCED_TYPENAME erase_key<S3,char>::type
|
||||||
|
, long
|
||||||
|
>::type >();
|
||||||
|
|
||||||
|
int_char_set_test<S2>();
|
||||||
|
int_char_set_test< BOOST_DEDUCED_TYPENAME insert<
|
||||||
|
BOOST_DEDUCED_TYPENAME insert<S0,char>::type
|
||||||
|
, int
|
||||||
|
>::type >();
|
||||||
|
|
||||||
|
int_char_set_test< BOOST_DEDUCED_TYPENAME insert<S1,char>::type >();
|
||||||
|
int_char_set_test< BOOST_DEDUCED_TYPENAME erase_key<S3,long>::type >();
|
||||||
|
|
||||||
|
int_char_long_set_test<S3>();
|
||||||
|
int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert<
|
||||||
|
BOOST_DEDUCED_TYPENAME insert<
|
||||||
|
BOOST_DEDUCED_TYPENAME insert<S0,char>::type
|
||||||
|
, long
|
||||||
|
>::type
|
||||||
|
, int
|
||||||
|
>::type >();
|
||||||
|
|
||||||
|
int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert<
|
||||||
|
BOOST_DEDUCED_TYPENAME insert<S1,long>::type
|
||||||
|
, char
|
||||||
|
>::type >();
|
||||||
|
|
||||||
|
int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert<S2,long>::type >();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template< typename S1, typename S2 >
|
||||||
|
void numbered_vs_variadic_set_test()
|
||||||
|
{
|
||||||
|
MPL_ASSERT(( is_same< S1, BOOST_DEDUCED_TYPENAME S1::type > ));
|
||||||
|
MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME S2::type, S1 > ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MPL_TEST_CASE()
|
MPL_TEST_CASE()
|
||||||
{
|
{
|
||||||
typedef set0<> s;
|
typedef mpl::set0<> s01;
|
||||||
|
typedef mpl::set<> s02;
|
||||||
MPL_ASSERT_RELATION( size<s>::value, ==, 0 );
|
typedef mpl::set1<int> s11;
|
||||||
MPL_ASSERT(( empty<s> ));
|
typedef mpl::set<int> s12;
|
||||||
MPL_ASSERT(( is_same< clear<s>::type, set0<> > ));
|
typedef mpl::set2<int,char> s21;
|
||||||
MPL_ASSERT(( is_same< at<s,char>::type, void_ > ));
|
typedef mpl::set<int,char> s22;
|
||||||
|
typedef mpl::set<char,int> s23;
|
||||||
|
typedef mpl::set3<int,char,long> s31;
|
||||||
|
typedef mpl::set<int,char,long> s32;
|
||||||
|
typedef mpl::set<int,long,char> s33;
|
||||||
|
typedef mpl::set<long,char,int> s34;
|
||||||
|
|
||||||
|
numbered_vs_variadic_set_test<s01,s02>();
|
||||||
|
numbered_vs_variadic_set_test<s11,s12>();
|
||||||
|
numbered_vs_variadic_set_test<s21,s22>();
|
||||||
|
numbered_vs_variadic_set_test<s31,s32>();
|
||||||
|
|
||||||
|
basic_set_test<s01,s11,s21,s31>();
|
||||||
|
basic_set_test<s02,s12,s22,s32>();
|
||||||
|
basic_set_test<s01,s11,s23,s31>();
|
||||||
|
basic_set_test<s01,s11,s23,s33>();
|
||||||
|
basic_set_test<s01,s11,s23,s34>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template< typename s >
|
||||||
|
void empty_set_types_variety_test()
|
||||||
|
{
|
||||||
MPL_ASSERT_NOT(( has_key<s,char> ));
|
MPL_ASSERT_NOT(( has_key<s,char> ));
|
||||||
MPL_ASSERT_NOT(( has_key<s,int> ));
|
MPL_ASSERT_NOT(( has_key<s,int> ));
|
||||||
MPL_ASSERT_NOT(( has_key<s,UDT> ));
|
MPL_ASSERT_NOT(( has_key<s,UDT> ));
|
||||||
@@ -123,27 +269,12 @@ MPL_TEST_CASE()
|
|||||||
MPL_ASSERT_NOT(( has_key<s,int&> ));
|
MPL_ASSERT_NOT(( has_key<s,int&> ));
|
||||||
MPL_ASSERT_NOT(( has_key<s,UDT&> ));
|
MPL_ASSERT_NOT(( has_key<s,UDT&> ));
|
||||||
MPL_ASSERT_NOT(( has_key<s,incomplete&> ));
|
MPL_ASSERT_NOT(( has_key<s,incomplete&> ));
|
||||||
|
|
||||||
typedef insert<s,char>::type s1;
|
|
||||||
MPL_ASSERT_RELATION( size<s1>::value, ==, 1 );
|
|
||||||
MPL_ASSERT(( is_same< at<s1,char>::type, char > ));
|
|
||||||
|
|
||||||
typedef erase_key<s,char>::type s0_1;
|
|
||||||
MPL_ASSERT_RELATION( size<s0_1>::value, ==, 0 );
|
|
||||||
MPL_ASSERT(( is_same< at<s0_1,char>::type, void_ > ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MPL_TEST_CASE()
|
template< typename s >
|
||||||
|
void set_types_variety_test()
|
||||||
{
|
{
|
||||||
typedef set<
|
|
||||||
char,int const,long*,UDT* const,incomplete,abstract
|
|
||||||
, incomplete volatile&,abstract const&
|
|
||||||
> s;
|
|
||||||
|
|
||||||
MPL_ASSERT_RELATION( size<s>::value, ==, 8 );
|
MPL_ASSERT_RELATION( size<s>::value, ==, 8 );
|
||||||
MPL_ASSERT_NOT(( empty<s> ));
|
|
||||||
MPL_ASSERT(( is_same< clear<s>::type, set0<> > ));
|
|
||||||
MPL_ASSERT(( is_same< at<s,bool>::type, void_ > ));
|
|
||||||
|
|
||||||
MPL_ASSERT(( has_key<s,char> ));
|
MPL_ASSERT(( has_key<s,char> ));
|
||||||
MPL_ASSERT(( has_key<s,int const> ));
|
MPL_ASSERT(( has_key<s,int const> ));
|
||||||
@@ -164,9 +295,24 @@ MPL_TEST_CASE()
|
|||||||
MPL_ASSERT_NOT(( has_key<s,abstract&> ));
|
MPL_ASSERT_NOT(( has_key<s,abstract&> ));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use a template for testing so that GCC will show us the actual types involved
|
|
||||||
|
MPL_TEST_CASE()
|
||||||
|
{
|
||||||
|
empty_set_types_variety_test< set<> >();
|
||||||
|
empty_set_types_variety_test< set<>::type >();
|
||||||
|
|
||||||
|
typedef set<
|
||||||
|
char,int const,long*,UDT* const,incomplete,abstract
|
||||||
|
, incomplete volatile&,abstract const&
|
||||||
|
> s;
|
||||||
|
|
||||||
|
set_types_variety_test<s>();
|
||||||
|
set_types_variety_test<s::type>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
void test()
|
void find_test()
|
||||||
{
|
{
|
||||||
MPL_ASSERT_RELATION( size<S>::value, ==, 3 );
|
MPL_ASSERT_RELATION( size<S>::value, ==, 3 );
|
||||||
|
|
||||||
@@ -179,12 +325,7 @@ void test()
|
|||||||
|
|
||||||
MPL_TEST_CASE()
|
MPL_TEST_CASE()
|
||||||
{
|
{
|
||||||
typedef mpl::set<int> set_of_1_int;
|
typedef mpl::set<int,long,char> s;
|
||||||
typedef mpl::begin<set_of_1_int>::type iter_to_1_int;
|
find_test<s>();
|
||||||
BOOST_MPL_ASSERT(( is_same< deref<iter_to_1_int>::type, int > ));
|
find_test<s::type>();
|
||||||
|
|
||||||
typedef mpl::set<int,long,char> myset;
|
|
||||||
|
|
||||||
test<myset>();
|
|
||||||
test<myset::type>();
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user