Boost logo

Boost :

From: Thomas Witt (witt_at_[hidden])
Date: 2005-08-16 17:54:08


Mat,

Mat Marcus wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> In one of our projects, the following code produces some strange
> compilation errors under VC 7.1/boost 1.33.0. Can anyone suggest a
> workaround?
>
> - Mat
>
> #include <sstream>
> #include "boost/type_traits.hpp"
> #include "boost/utility/enable_if.hpp"
>
> template <typename EnumType>
> typename boost::enable_if<boost::is_enum<EnumType>, EnumType>::type
> operator ~ (EnumType a);

I can't say whether that is your problem, but code like this is
potentially dangerous. It'll break whenever you happen to "suck" in a
use of operator~ on an unnamed enum. And yes it tends to generate weird
error messages. Looking at the errors the unknown type in the is_enum
instantiation looks suspicious to me.

I only have apples gcc 4 currently. A slightly modified example gives this:

enum { foo, bar };

template <typename EnumType>
typename boost::enable_if<boost::is_enum<EnumType>, EnumType>::type
operator ~ (EnumType a);

int main()
{

   int i = ~bar;

std::stringstream t;

}

mat.cpp: In function 'int main()':
mat.cpp:14: error: '<anonymous enum>' is/uses anonymous type
mat.cpp:14: error: trying to instantiate 'template<class T> struct
boost::is_enum'

Thomas

>
> std::stringstream t;
>
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGP Desktop 9.0.2 (Build 2424)
>
> iQA/AwUBQwIDTxIZBaoznf65EQKEyACgnVW7095czvJp1MMvNruggOxQfIQAn2Qs
> TAtl4P353L4rRplTeFJwW2kO
> =jqlu
> -----END PGP SIGNATURE-----
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk