[cfe-commits] [Patch][Review] constexpr-ification of <limits> and random number generators
Howard Hinnant
hhinnant at apple.com
Mon Apr 2 14:02:24 PDT 2012
On Apr 2, 2012, at 4:41 PM, Jonathan Sauer wrote:
> Hello,
>
>>> It would be possible, of course, to conditionally define those constants to either use min() and max()
>>> or _Min and _Max, respectively:
>>>
>>> #if _LIBCPP_HAS_NO_CONSTEXPR
>>> static const result_type _Min = _Engine::_Min;
>>> static const result_type _Max = _Engine::_Max;
>>> #else
>>> static _LIBCPP_CONSTEXPR const result_type _Min = _Engine::min();
>>> static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max();
>>> #endif
>>>
>>> But this would depend on the non-standard members _Min and _Max. And it would complicate the source, too.
>>>
>>> What do you think?
>>
>> This looks like the way to go to me. I count 3 places in <random> and 1 place in <algorithm> that need this treatment. User-written engines will either have to -std=c++11, or provide the non-standard interface. I don't see another way around this.
>
> I have changed <random> and <algorithm> accordingly and attached the new patch. numerics/rand tests pass
> in C++03 and C++11 mode (except for the tests involving initializer_list).
>
>
> Jonathan
> <random.diff>
Committed revision 153896.
Thanks!
Howard
More information about the cfe-commits
mailing list