// 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. // $Id$ // $Date$ // $Revision$ #include #include #include #include #include #include #include #include #include #include #include #include #include #include MPL_TEST_CASE() { typedef map2< mpl::pair , mpl::pair > m_; typedef erase_key::type m; MPL_ASSERT_RELATION( size::type::value, ==, 1 ); MPL_ASSERT_NOT(( empty )); MPL_ASSERT(( is_same< clear::type,map0<> > )); MPL_ASSERT(( is_same< at::type,unsigned > )); MPL_ASSERT(( is_same< at::type,void_ > )); MPL_ASSERT(( contains< m,mpl::pair > )); MPL_ASSERT_NOT(( contains< m,mpl::pair > )); MPL_ASSERT_NOT(( contains< m,mpl::pair > )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT(( has_key::type )); MPL_ASSERT_NOT(( is_same< order::type, void_ > )); MPL_ASSERT(( is_same< order::type,void_ > )); typedef begin::type first; typedef end::type last; MPL_ASSERT(( is_same< deref::type,mpl::pair > )); MPL_ASSERT(( is_same< next::type,last > )); typedef insert >::type m2; MPL_ASSERT_RELATION( size::type::value, ==, 2 ); MPL_ASSERT_NOT(( empty::type )); MPL_ASSERT(( is_same< clear::type,map0<> > )); MPL_ASSERT(( is_same< at::type,unsigned > )); MPL_ASSERT(( is_same< at::type,long > )); MPL_ASSERT(( contains< m2,mpl::pair > )); MPL_ASSERT_NOT(( contains< m2,mpl::pair > )); MPL_ASSERT_NOT(( contains< m2,mpl::pair > )); MPL_ASSERT(( contains< m2,mpl::pair > )); MPL_ASSERT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( is_same< order::type, void_ > )); MPL_ASSERT_NOT(( is_same< order::type, void_ > )); MPL_ASSERT_NOT(( is_same< order::type, order::type > )); typedef begin::type first2; typedef end::type last2; MPL_ASSERT(( is_same::type,mpl::pair > )); typedef next::type iter; MPL_ASSERT(( is_same::type,mpl::pair > )); MPL_ASSERT(( is_same< next::type,last2 > )); typedef insert >::type s2_1; MPL_ASSERT(( is_same )); typedef insert >::type m3; MPL_ASSERT_RELATION( size::type::value, ==, 3 ); MPL_ASSERT(( has_key::type )); MPL_ASSERT(( has_key::type )); MPL_ASSERT(( has_key::type )); MPL_ASSERT(( contains< m3,mpl::pair > )); MPL_ASSERT(( contains< m3,mpl::pair > )); typedef insert >::type m1; MPL_ASSERT_RELATION( size::type::value, ==, 2 ); MPL_ASSERT(( is_same< at::type,unsigned > )); MPL_ASSERT(( is_same< at::type,long > )); MPL_ASSERT(( contains< m1,mpl::pair > )); MPL_ASSERT_NOT(( contains< m1,mpl::pair > )); MPL_ASSERT_NOT(( contains< m1,mpl::pair > )); MPL_ASSERT(( contains< m1,mpl::pair > )); MPL_ASSERT(( is_same< m1,m2 > )); typedef erase_key::type m_1; MPL_ASSERT(( is_same )); MPL_ASSERT_RELATION( size::type::value, ==, 1 ); MPL_ASSERT(( is_same< at::type,void_ > )); MPL_ASSERT(( is_same< at::type,unsigned > )); typedef erase_key::type m2_1; MPL_ASSERT_RELATION( size::type::value, ==, 2 ); MPL_ASSERT(( is_same< at::type,void_ > )); MPL_ASSERT(( is_same< at::type,unsigned > )); MPL_ASSERT(( is_same< at::type,unsigned > )); } MPL_TEST_CASE() { typedef map0<> m; MPL_ASSERT_RELATION( size::type::value, ==, 0 ); MPL_ASSERT(( empty::type )); MPL_ASSERT(( is_same< clear::type,map0<> > )); MPL_ASSERT(( is_same< at::type,void_ > )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); MPL_ASSERT_NOT(( has_key::type )); typedef insert >::type m1; MPL_ASSERT_RELATION( size::type::value, ==, 1 ); MPL_ASSERT(( is_same< at::type,int > )); typedef erase_key::type m0_1; MPL_ASSERT_RELATION( size::type::value, ==, 0 ); MPL_ASSERT(( is_same< at::type,void_ > )); } // 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 map< mpl::pair > map_of_1_pair; typedef begin::type iter_to_1_pair; BOOST_MPL_ASSERT(( is_same< deref::type , mpl::pair > )); typedef map< mpl::pair , mpl::pair , mpl::pair > mymap; test(); test(); } MPL_TEST_CASE() { typedef mpl::erase_key< mpl::map< mpl::pair , mpl::pair > , char >::type int_to_float_map; typedef mpl::insert< int_to_float_map , mpl::pair >::type with_char_too; BOOST_MPL_ASSERT(( boost::is_same< mpl::at::type , long > )); } MPL_TEST_CASE() { typedef insert< map<>, pair >::type little_map; MPL_ASSERT_RELATION(size::value, ==, 1); MPL_ASSERT_RELATION(size::value, ==, 1); } MPL_TEST_CASE() { typedef erase_key< map< pair, pair >, float >::type little_map; MPL_ASSERT_RELATION(size::value, ==, 1); MPL_ASSERT_RELATION(size::value, ==, 1); }