[cfe-commits] [Patch][Review] constexpr-ification of <limits> and random number generators

Jonathan Sauer jonathan.sauer at gmx.de
Mon Apr 2 13:41:34 PDT 2012


>> It would be possible, of course, to conditionally define those constants to either use min() and max()
>> or _Min and _Max, respectively:
>>   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).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: random.diff
Type: application/octet-stream
Size: 22063 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120402/5b7b1f90/attachment.obj>
-------------- next part --------------

More information about the cfe-commits mailing list