31auto narrow(FROM from)
noexcept -> TO {
32 static_assert(std::is_arithmetic_v<TO>,
"TO must be an arithmetic type");
33 const TO to =
static_cast<TO
>(std::forward<FROM>(from));
34 if constexpr (std::is_arithmetic_v<TO>) {
35 LF_ASSERT_MSG(
static_cast<FROM
>(to) == from &&
36 (std::is_signed_v<FROM> == std::is_signed_v<TO> ||
37 ((to < TO{}) == (from < FROM{}))),
40 LF_ASSERT_MSG(
static_cast<FROM
>(to) == from,
"Narrowing error.");