Skip to content

mp_units::utility::value_fits_in

Is value still representable in To after truncation?

Synopsis

Declared in <mp-units/framework/scaling.h>

template<typename To, typename From>
[[nodiscard]] constexpr bool value_fits_in(From const& value);

Description

Answers true for any pair the question does not apply to, which is every case except a floating-point source with an integral target. That case is the one where the conversion is undefined rather than merely lossy, and it is not what std::in_range answers: its Mandates require both types to be standard or extended integer types, so a floating-point source is ill-formed there.

Return Value

Note

The return value should not be discarded.