//prototype whether initial mpl::set can be done by using repeated inserts. // #include #include #include #include #include #include #include #include #include namespace boost{namespace mpl{ namespace assoc_impl //prototype namespace: { #define USE_SET_INSERT #ifdef USE_SET_INSERT //{set template < typename... Elements > struct set ; template < > struct set < > : mpl::set<> { }; template < typename HeadElement , typename... TailElements > struct set < HeadElement , TailElements... > : mpl::insert < assoc_impl::set , HeadElement >::type { }; //}set template < typename Set0 , typename Set1 > struct erase_sets /**@brief * erases Set1 from Set0 */ : fold < Set1 , Set0 , erase_key,arg<2> > > { }; template < typename Set0 , typename Set1 > struct equal_sets /**@brief * Is Set1 equal to Set0? */ : and_ < empty::type> , empty::type> > { }; #endif void set_insert_erase_test(void) { typedef set<> empty_set; typedef insert::type set_int; BOOST_MPL_ASSERT((has_key)); typedef insert::type set_int_float; BOOST_MPL_ASSERT((has_key)); BOOST_MPL_ASSERT((has_key)); typedef insert::type set_int_float_int; BOOST_MPL_ASSERT((boost::is_same)); typedef erase_key::type set_int_float_erase_float; BOOST_MPL_ASSERT((boost::is_same)); typedef insert::type set_float; typedef erase_key::type set_int_float_erase_int; BOOST_MPL_ASSERT_NOT((boost::is_same)); BOOST_MPL_ASSERT((equal)); typedef insert::type set_float_int; BOOST_MPL_ASSERT_NOT((boost::is_same)); #ifdef USE_SET_INSERT #if 0 typedef erase_sets::type erase_sets_result; BOOST_MPL_ASSERT((is_same)); #endif BOOST_MPL_ASSERT((equal_sets)); BOOST_MPL_ASSERT_NOT((equal_sets)); BOOST_MPL_ASSERT_NOT((equal_sets)); #endif } void set_dup_key_con_test(void) { typedef ::boost::mpl:: #ifdef USE_SET_INSERT assoc_impl:: #endif set < int , int > int2_set; BOOST_MPL_ASSERT((has_key)); unsigned const size_int2_set=size::type::value; BOOST_MPL_ASSERT_RELATION(size_int2_set,==,1); //^1)according to "normal: interpretation of "set". typedef erase_key::type int2_erase_int; unsigned const size_int2_erase_int=size::type::value; BOOST_MPL_ASSERT_RELATION(size_int2_erase_int,==,0); BOOST_MPL_ASSERT_NOT((has_key)); //^2)according to "Semantics:" on: // http://www.boost.org/libs/mpl/doc/refmanual/erase-key.html typedef erase_key::type int2_erase_float; unsigned const size_int2_erase_float=size::type::value; BOOST_MPL_ASSERT_RELATION(size_int2_erase_float,==,1); //^3)according to "Postcondition:" on: // http://www.boost.org/libs/mpl/doc/refmanual/erase-key.html } }//exit assoc_impl namespace }}//exit boost::mpl