Aleksey Gurtovoy wrote:
With the current CVS, you don't have to do it by yourself:
#include "boost/mpl/vector.hpp" #include "boost/mpl/switch.hpp" #include "boost/mpl/project1st.hpp" #include "boost/mpl/pair.hpp" #include "boost/mpl/always.hpp" #include "boost/mpl/bool_c.hpp" #include "boost/mpl/assert_is_same.hpp"
#include "boost/type_traits/remove_reference.hpp" #include "boost/type_traits/add_const.hpp" #include "boost/type_traits/is_pointer.hpp" #include "boost/type_traits/is_reference.hpp"
using namespace boost::mpl;
typedef vector< pair< boost::is_pointer<_1>, _1 > , pair< boost::is_reference<_1>, boost::remove_reference<_1> > , pair< always
, boost::add_const<_1> > > switch_body; typedef switch_< switch_body, char& >::type t1; typedef switch_< switch_body, int* >::type t2; typedef switch_< switch_body, int >::type t3;
BOOST_MPL_ASSERT_IS_SAME(t1, char); BOOST_MPL_ASSERT_IS_SAME(t2, int*); BOOST_MPL_ASSERT_IS_SAME(t3, int const);
Does it cover your needs?
It covers my needs and it makes me feel like a stupid KnowNothing (after 5 years in expression template metaprogramming) What are the requirements for the struct some_condition<_1> to be used in such a switch body? Markus