53 template<
class U,
class T>
55 using lim_T = std::numeric_limits<T>;
56 using lim_U = std::numeric_limits<U>;
58 if constexpr (lim_T::is_integer && lim_U::is_integer) {
59 if constexpr (lim_T::is_signed) {
60 if constexpr (lim_U::is_signed) {
62 return val >= lim_U::min() && val <= lim_U::max();
65 return val >= 0 &&
static_cast<std::make_unsigned_t<T>
>(val) <= lim_U::max();
68 if constexpr (lim_U::is_signed) {
73 return val <= lim_U::max();
82 template<
class U,
class T>
88 return static_cast<U>(val);
90 using lim_U = std::numeric_limits<U>;
92 "value {} cannot be narrowed to type U (see signature) static_cast<U>({}) = {} "
93 "(U::min() = {}, U::max() = {})",
This header file contains utility functions related to exception handling in the code.
namespace for basic c++ utilities
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
constexpr bool can_narrow(T val)
Check if an integer value can be safely narrowed to a target type.
This file contains the definition for the stacktrace related functionality.
#define __shamrock_log_callsite(callsite)
Macro to create a stack entry from a given location. Can be used only on SourceLocation &&.
provide information about the source location