Boost logo

Boost Users :

Subject: [Boost-users] problem with boost::is_same
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-01-17 16:53:44


I have a question about the following code:

    typedef void(intArrayParamFunc)(int[]);
    typedef void(intPtrParamFunc)(int*);

BOOST_STATIC_ASSERT((boost::is_same<intArrayParamFunc,intPtrParamFunc>::value));
    BOOST_STATIC_ASSERT((boost::is_same<int*,int[]>::value));

    cout << typeid(intArrayParamFunc).name() << endl;
    cout << typeid(intPtrParamFunc).name() << endl;

    cout << typeid(int*).name() << endl;
    cout << typeid(int[]).name() << endl;

The first assert compiles but the second fails, which means that
boost::is_same<> thinks that int* and int[] are different, but void(int[])
and void(int*) are the same. Why is this?

The typeids print out the following:

void __cdecl(int * const)
void __cdecl(int *)
int *
int [0]

I'm using Visual Studio 2008. I notice that typeid tells me that
intArrayParamFunc is void(int* const). So why does boost::is_same<> compare
them equal? Surely void(int* const) should not be the same type as
void(int*). Unless this is just some obscure language subtlety I'm not
aware of. So is this a bug in boost::is_same<>, a bug in my compiler, or no
bugs at all and everything is working perfectly?



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net