Boost logo

Boost :

Subject: Re: [boost] [Better Enums] More complete release - feedback requested
From: Anton Bachin (antonbachin_at_[hidden])
Date: 2015-06-11 09:47:57


> On Jun 11, 2015, at 03:12, Sam Kellett <samkellett_at_[hidden]> wrote:
>
> Channel::_from_string(“Red”);
>> vs.
>> better_enums::traits<Channel>::from_string(“Red”);
>>
>> I could get some degree of type inference to happen by wrapping the traits
>> functions in freestanding template functions, but it was still too verbose
>> (IMO), and also threw away the advantage of a uniform and easy-to-remember
>> interface.
>>
>
> I would prefer free-functions in a namespace. Something like:
>
> better_enums::from_string<Channel>("Red");
>
> (although I think the namespace is too long. Maybe just 'enums’?)

That’s exactly what I ended up with. Ok, I’ll update and publish the traits
branch again in a few days, and adapt some examples so that it’s easy to
compare.

>> [snip]
>>
>>> B. make size a constexpr function
>
>
> +1
>
> I think you should look to the future and give pay-off to people using more
> modern C++. However you can macro-ize the constexpr keyword so that it is
> constexpr is supported or nothing if not.
>
> BOOST_NO_CXX11_CONSTEXPR will do the check for you.

I’ve already done this, and I use it throughout enum.h. It’s not a problem to
make a size() function constexpr only when supported, I am just not so
comfortable throwing away size as an integral constant for non-C++11 users.
Perhaps I can make size() a function and provide an alternative constant with an
ugly name for those who might need it? Do people still use C++03? And, again,
what is the rationale for size being a function?


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