10 #ifndef CPROVER_UTIL_ARITH_TOOLS_H 11 #define CPROVER_UTIL_ARITH_TOOLS_H 25 DEPRECATED(
"Use the constant_exprt version instead")
37 template <typename Target, typename =
void>
58 typename
std::enable_if<std::is_integral<T>::value>::type>
62 template <
typename U = T,
63 typename std::enable_if<std::is_signed<U>::value,
int>::type = 0>
70 template <
typename U = T,
71 typename std::enable_if<!std::is_signed<U>::value,
int>::type = 0>
74 return mpi.to_ulong();
81 #if !defined(_MSC_VER) || _MSC_VER >= 1900 83 std::numeric_limits<T>::max() <=
84 std::numeric_limits<decltype(get_val(mpi))>::max() &&
85 std::numeric_limits<T>::min() >=
86 std::numeric_limits<decltype(get_val(mpi))>::min(),
87 "Numeric cast only works for types smaller than long long");
92 std::numeric_limits<T>::max() <=
93 std::numeric_limits<decltype(get_val(mpi))>::max() &&
94 std::numeric_limits<T>::min() >=
95 std::numeric_limits<decltype(get_val(mpi))>::min());
98 mpi <= std::numeric_limits<T>::max() &&
99 mpi >= std::numeric_limits<T>::min())
101 return static_cast<T
>(get_val(mpi));
121 template <
typename Target>
133 template <
typename Target>
147 template <
typename Target>
166 #endif // CPROVER_UTIL_ARITH_TOOLS_H The type of an expression.
static auto get_val(const mp_integer &mpi) -> decltype(mpi.to_long())
Numerical cast provides a unified way of converting from one numerical type to another.
A constant literal expression.
#define INVARIANT(CONDITION, REASON)
Convert expression to mp_integer.
const irep_idt & id() const
static auto get_val(const mp_integer &mpi) -> decltype(mpi.to_ulong())
DEPRECATED("use instrument_cover_goals(goto_programt &goto_program," "const cover_instrumenterst &instrumenters," "message_handlert &message_handler, const irep_idt mode) instead") void instrument_cover_goals(const symbol_tablet &symbol_table
Instruments goto program for a given coverage criterion.
optionalt< T > operator()(const exprt &expr) const
nonstd::optional< T > optionalt
API to expression classes.
#define PRECONDITION(CONDITION)
optionalt< mp_integer > operator()(const exprt &expr) const
const constant_exprt & to_constant_expr(const exprt &expr)
Cast a generic exprt to a constant_exprt.
optionalt< T > operator()(const mp_integer &mpi) const
Base class for all expressions.