Hello,
I've just tried to compile a small piece of code using mpl::switch_
starting from an example Aleksey Gurtovoy sent to this list a while ago.
I slightly modified the code to use the boost::is_same template but
I can't make it compile. On the other hand, if I comment out the line in
the switch_body containing the is_same template, it compile without any
problem.
I spent the whole day on this and I'm lost. Any help would be welcome.
Thanks,
Istvan
PS: I'm using boost 1.30.2 and g++ 3.3.3.
#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.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"
#include "boost/type_traits/is_same.hpp"
using namespace boost::mpl ;
using boost::mpl::_ ;
struct MyType
{
typedef int type ;
} ;
int main()
{
typedef vector<
pair< boost::is_pointer<_1>, _1 >
// If the following line is commented out it compile.
, pair< boost::is_same<_1, _1 >, boost::add_const<_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);
}