Boost logo

Boost :

Subject: Re: [boost] Enum Conversion
From: Roland Bock (rbock_at_[hidden])
Date: 2012-09-04 07:43:53


On 2012-09-04 12:43, Vicente J. Botet Escriba wrote:
> Le 04/09/12 01:01, Ilya Bobyr a écrit :
>> On 9/2/2012 1:46 PM, Vicente J. Botet Escriba wrote:
>>> [...]
>>> I managed defining a specific opaque type, let me say MyGreek, and
>>> defining implicit conversions from these types.
>>>
>>> Your example could be written as
>>>
>>> std::cout << string(MyGreek(1)) << std::endl;
>>> std::cout << string(MyGreek(6)) << std::endl;
>>> std::cout << MyGreek(Alpha) << std::endl;
>>> std::cout << MyGreek::Alpha << std::endl; // using nested literal
>>> std::cout << string(MyGreek(Alpha)) << std::endl;
>>> std::cout << string(MyGreek::Alpha) << std::endl; // using nested
>>> literal
>>> std::cout << MyGreek(17) << std::endl;
>>>
>>>
>>> If think this interface corresponds more to how C++ conversions work
>>> (IMO of course).
>>>
>>>
>>>> (Or
>>>> does boost even offer something like that already?)
>>> I don't think so. The closest could be TBoost.Enums in the sandbox,
>>> but this library generates the enum and don't do the mapping.
>>
>> I think that it can do both plain enums and enums that map to
>> arbitrary types. Here is an example where string are associated with
>> enum values:
>>
>> http://stackoverflow.com/a/439004
>>
>>
> Hi,
>
> The link correspond to Boost.Enum, I was talking about TBoost.Enums
> (https://svn.boost.org/svn/boost/sandbox/enums/libs/enums/doc/html/index.html).
>
> Best,
> Vicente
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost

I am sooo looking forward to using C++11 :-)

Currently I am working with explicit conversion functions. I am aiming
for the implicit version suggested by you once I can use class enums.

Regards,

Roland


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