9#ifndef CPROVER_UTIL_NARROW_H
10#define CPROVER_UTIL_NARROW_H
18template <
typename output_type,
typename input_type>
22 std::is_arithmetic<input_type>::value &&
23 std::is_arithmetic<output_type>::value,
24 "narrow_cast is intended only for numeric conversions");
33template <
typename output_type,
typename input_type>
36 const auto output =
static_cast<output_type>(input);
43template <
typename output_type,
typename input_type>
49 throw std::out_of_range{
"narrowing gave a different value than expected"};
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
output_type narrow(input_type input)
Run-time checked narrowing cast.
output_type narrow_or_throw_out_of_range(input_type input)
Run-time checked narrow cast.
output_type narrow_cast(input_type value)
Alias for static_cast intended to be used for numeric casting Rationale: Easier to grep than static_c...
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.