Boost logo

Boost :

Subject: Re: [boost] [Better Enums] More complete release - feedback requested
From: Thorsten Ottosen (tottosen_at_[hidden])
Date: 2015-06-11 10:46:49


On 11-06-2015 15:47, Anton Bachin wrote:

>>> [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?

It's more generic if you want to view the class as a container with
size() and begin()/end().

Yes, people still used C++03, but I'm sure they can live with a
non-constexpr size() that is every bit as fast at runtime as a constexpr
one.

-Thorsten


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