Boost logo

Boost :

Subject: Re: [boost] [core] Breaking bugfix in scoped enums
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2014-06-06 19:12:32


On Saturday 07 June 2014 01:04:28 Vicente J. Botet Escriba wrote:
> Le 07/06/14 00:41, Andrey Semashev a écrit :
> > resulted in the enums being convertible to int. This is a potentially
> > breaking>
> > change, the code like this will now not compile:
> > BOOST_SCOPED_ENUM_DECLARE_BEGIN(color)
> > {
> >
> > red, green, blue
> >
> > }
> > BOOST_SCOPED_ENUM_DECLARE_END(color)
> >
> > void foo(boost::native_type<color>::type col);
> >
> > color col = color::blue;
> > foo(col);
> >
> > The call to foo() should be done like this:
> > foo(boost::native_value(col));
> >
> > Previously, the conversion was implicit.
>
> Yes, this is a breaking change. The implicit conversion from EnumType to
> enum_type was intentional.
>
> operator enum_type() const BOOST_NOEXCEPT { return get_native_value_(); }
>
> I was expecting two implicit conversions: one from EnumType to enum_type
> and the other from enum_type to int. Am I missing something in C++98?

I'll have to check later, but scoped_enum_compile_fail_conv_to_int.cpp test
fails with clang 3.4 in C++03 mode with this operator.


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