Boost logo

Boost Users :

From: Romain Lerallut (rlerallut_at_[hidden])
Date: 2003-10-02 09:10:17


In the following code, struct foo2 is mistakenly taken for an enum, which
breaks is_class, which leads to some unfortunate problems in boost::python.

Problem appears on both Boost 1.30.0 and a one-month old CVS checkout, using
gcc 3.3.2 and 2.95 and Intel icc 7.1 for linux.

I have tried specializing 'is_enum', setting it by hand to return 'false',
but though it works for this simple case, it does no good when the call to
is_enum is buried deep inside boost.

I rely heavily on being able to do these implicit conversions for foo2, so if
anyone has an idea on how to make this work, it would be great.

Thanks in advance,
Romain

----------------------------------------------------------------
#include <boost/type_traits/is_enum.hpp>
#include <iostream>

struct foo1 // this one is not detected as an enum
{
        operator int() { return 0; }
};

struct foo2 // this one *is* detected as an enum
{
        template<typename T> operator T(){return 0;}
};

int main()
{
        std::cout<<boost::is_enum<int>::value<<"\n";
        std::cout<<boost::is_enum<foo1>::value<<"\n";
        std::cout<<boost::is_enum<foo2>::value<<"\n";

}
--------------------------------------------------------------
Expected Result:
0
0
0
Actual Result:
0
0
1


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