Boost logo

Boost :

Subject: Re: [boost] Enum Conversion
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2012-09-04 06:43:57


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


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