[C++-sig] Re: Re: Re: enum_ exporting implemented
dave at boost-consulting.com
Sat Dec 14 02:08:10 CET 2002
"Mike Rovner" <mike at bindkey.com> writes:
> "David Abrahams" <dave at boost-consulting.com> wrote in message
> news:u4r9hmozd.fsf at boost-consulting.com...
>> "Mike Rovner" <mike at bindkey.com> writes:
>> >> >>>> identity(color(3))
>> >> > enums.color(3)
>> >> >
>> >> > a mistake? There is no 3 in example enum.
>> > I mean not how it is working, but how it shall work.
>> > If it's a legitimate behavior, please, explain why.
>> It mirrors the behavior of C++ enums.
> Shall we follow all bad design? ;)
Yes <wink>. Especially without any justification for calling it "bad"
>> Why do you think it's illegitimate?
> Because there is no 3 in original enum.
>> What do you think enums.color.red + enums.color.green should do?
> Return integer 3.
> (Like in Python: False + True is just 1 and only for backward compatibility
In this case, enums are often used for flag values, and combinations
of the flags are common. It is a fact that all values with the same
number of bits as the maximum value of the enum are legitimate values
of the enum in C++, even if they're never named. It simply wouldn't
work right if values not explicitly exported were not allowed, and
requiring the user to export all 2147483648 possible values of her
enum is IMO impractical.
> All that is IMHO without pretending to know better.
dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution
More information about the Cplusplus-sig