From: Ivan Matek (libbooze_at_[hidden])
Date: 2025-01-18 20:30:18


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.