|
Boost : |
Subject: Re: [boost] [core] Breaking bugfix in scoped enums
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2014-06-06 19:04:28
Le 07/06/14 00:41, Andrey Semashev a écrit :
> Hi,
>
> While creating tests for scoped enums emulation I've fixed a bug which
Thnaks for fixing this
typename EnumType::enum_type native_value(EnumType e)
{
- return e.native_value_();
+ return e.get_native_value_();
}
> 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?
Vicente
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk