10#include <userver/compiler/demangle.hpp>
12USERVER_NAMESPACE_BEGIN
19using PrintableValue = std::conditional_t<(
sizeof(T) > 1), T,
int>;
29template <
typename U,
typename T>
31 static_assert(std::is_integral_v<T>);
32 static_assert(std::is_integral_v<U>);
35 if (
static_cast<T>(result) != input || ((result < 0) != (input < 0))) {
36 throw std::runtime_error(fmt::format(
37 "Failed to convert {} {} into {} due to integer overflow",
39 static_cast<impl::PrintableValue<T>>(input),