// Copyright Aleksey Gurtovoy 2003-2004 // Copyright David Abrahams 2003-2004 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/mpl for documentation. // $Source: /cvsroot/boost/boost/libs/mpl/test/set.cpp,v $ // $Date: 2006/06/12 05:11:55 $ // $Revision: 1.11.2.1 $ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include MPL_TEST_CASE() { typedef s_mask > > > s; MPL_ASSERT_RELATION( size::value, ==, 1 ); MPL_ASSERT_NOT(( empty )); MPL_ASSERT(( is_same< clear::type, set0<> > )); MPL_ASSERT(( is_same< at::type, int > )); MPL_ASSERT(( is_same< at::type, void_ > )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT(( has_key )); MPL_ASSERT_RELATION( (order::value), ==, 3 ); MPL_ASSERT(( is_same< order::type, void_ > )); typedef begin::type first; typedef end::type last; MPL_ASSERT(( is_same< deref::type, int > )); MPL_ASSERT(( is_same< next::type, last > )); typedef s_unmask s2; MPL_ASSERT_RELATION( size::value, ==, 2 ); MPL_ASSERT_NOT(( empty )); MPL_ASSERT(( is_same::type, set0<> > )); MPL_ASSERT(( is_same::type, int > )); MPL_ASSERT(( is_same::type, char > )); MPL_ASSERT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_RELATION( (order::value), ==, 3 ); MPL_ASSERT_RELATION( (order::value), ==, 2 ); typedef begin::type first2; typedef end::type last2; MPL_ASSERT(( is_same< deref::type, int > )); typedef next::type iter; MPL_ASSERT(( is_same< deref::type, char > )); MPL_ASSERT(( is_same< next::type, last2 > )); typedef insert::type s2_1; MPL_ASSERT(( is_same )); typedef insert::type s3; MPL_ASSERT_RELATION( size::value, ==, 3 ); MPL_ASSERT(( has_key )); MPL_ASSERT(( has_key )); MPL_ASSERT(( has_key )); typedef insert::type s1; MPL_ASSERT_RELATION( size::value, ==, 2 ); MPL_ASSERT(( is_same::type, int > )); MPL_ASSERT(( is_same::type, char > )); MPL_ASSERT_NOT(( is_same )); typedef erase_key::type s_1; MPL_ASSERT(( is_same )); MPL_ASSERT_RELATION( size::value, ==, 1 ); MPL_ASSERT(( is_same< at::type, void_ > )); MPL_ASSERT(( is_same< at::type, int > )); } MPL_TEST_CASE() { typedef set0<> s; MPL_ASSERT_RELATION( size::value, ==, 0 ); MPL_ASSERT(( empty )); MPL_ASSERT(( is_same< clear::type, set0<> > )); MPL_ASSERT(( is_same< at::type, void_ > )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); typedef insert::type s1; MPL_ASSERT_RELATION( size::value, ==, 1 ); MPL_ASSERT(( is_same< at::type, char > )); typedef erase_key::type s0_1; MPL_ASSERT_RELATION( size::value, ==, 0 ); MPL_ASSERT(( is_same< at::type, void_ > )); } MPL_TEST_CASE() { typedef set< char,int const,long*,UDT* const,incomplete,abstract , incomplete volatile&,abstract const& > s; MPL_ASSERT_RELATION( size::value, ==, 8 ); MPL_ASSERT_NOT(( empty )); MPL_ASSERT(( is_same< clear::type, set0<> > )); MPL_ASSERT(( is_same< at::type, void_ > )); MPL_ASSERT(( has_key )); MPL_ASSERT(( has_key )); MPL_ASSERT(( has_key )); MPL_ASSERT(( has_key )); MPL_ASSERT(( has_key )); MPL_ASSERT(( has_key )); MPL_ASSERT(( has_key )); MPL_ASSERT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); MPL_ASSERT_NOT(( has_key )); } // Use a template for testing so that GCC will show us the actual types involved template void test() { MPL_ASSERT_RELATION( size::value, ==, 3 ); typedef typename end::type not_found; BOOST_MPL_ASSERT_NOT(( is_same::type,not_found> )); BOOST_MPL_ASSERT_NOT(( is_same::type,not_found> )); BOOST_MPL_ASSERT_NOT(( is_same::type,not_found> )); BOOST_MPL_ASSERT(( is_same::type,not_found> )); } MPL_TEST_CASE() { typedef mpl::set set_of_1_int; typedef mpl::begin::type iter_to_1_int; BOOST_MPL_ASSERT(( is_same< deref::type, int > )); typedef mpl::set myset; test(); test(); }