utx::diff_size_cast is used to cast from one integral value to another integral value. If the value is greater than the max value of target type, or the value is less than the min value of target type, the compilation will fail.
template <utx::integral_meric target_type, utx::integral_meric auto source_value> requires (utx::in_scope(source_value, utx::min_v<target_type>, utx::max_v<target_type>)) constexpr inline target_type diff_size_cast = utx::meric_static_cast<target_type>(source_value);
#include <utxcpp/core.hpp> int main() { constexpr utx::i32 x = 123; constexpr auto x1 = utx::diff_size_cast<utx::i16, x>; constexpr utx::i32 x2 = 128; // Error: Constraint not satisfied. // (Because utx::i8_max is 127, x2 is greater than utx::i8_max) auto x3 = utx::diff_size_cast<utx::i8, x2>; }