|
Boost : |
From: Christopher Kormanyos (e_float_at_[hidden])
Date: 2025-01-18 20:34:40
>>Â A better option than failing here is probably to issue a warning, but
>> constexpr_warn_str is still years away.
>>
>Â Why not let users check the exactness of the initialization themselves?
Is there a <cmath> equivalent doing the samefor float, double, etc.?
I don't want to be some kind of a "downer"but it is not the place of decimal to extendthe standard library or its interpretation ofIEEE-754.
Just because you can do somethingdoes not mean you should.
- Chris
On Saturday, January 18, 2025 at 09:30:40 PM GMT+1, Ivan Matek via Boost <boost_at_[hidden]> wrote:
On Sat, Jan 18, 2025 at 6:57â¯PM Peter Dimov via Boost <boost_at_[hidden]>
wrote:
> A better option than failing here is probably to issue a warning, but
> constexpr_warn_str is still years away.
>
>
Why not let users check the exactness of the initialization themselves?
Something like:
static constexpr const char* init = "3.1415926535897932384626433";
and then user can do
template<typename Dec>
inline constexpr auto my_pi = exact_from_chars<Dec>(init);
Where exact_from_chars would fail(assert/throw/return ec/...) when decimal
number in string can not be exactly represented by Dec.
Obviously this should be done in a way that it is easy to transform the
init array(potentially multidimentional) into array of Dec, beside
supporting just scalar scenario, but this seems ok solution to me.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk