Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2025-01-16 16:45:18


Ruben Perez wrote:
> 4. From sprintf's documentation: "In the interest of safety sprintf simply calls
> snprintf with buf_size equal to sizeof(buffer). ". This doesn't look right. This is
> what the implementation looks like:
>
> template <typename... T>
> inline auto sprintf(char* buffer, const char* format, T... values) noexcept
> #ifndef BOOST_DECIMAL_HAS_CONCEPTS
> ->
> std::enable_if_t<detail::is_decimal_floating_point_v<std::common_type_t<T.
> ..>>,
> int>
> #else
> -> int requires
> detail::is_decimal_floating_point_v<std::common_type_t<T...>>
> #endif
...

It would be better to make the constraint say what we actually mean, namely,
"each type in T... should be integral, floating point, or decimal floating point".

Using something entirely different just because we think it's equivalent to the
above isn't superior in any way to just saying what we actually mean, even if
it were actually equivalent. (It isn't because common_type can be specialized
by the user.)

(Providing sprintf in 2025 is a bit debatable, std::format is the way to go here.)


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