1#ifndef SANISIZER_CAST_HPP
2#define SANISIZER_CAST_HPP
21template<
typename Dest_,
typename Value_>
23 static_assert(std::is_integral<Dest_>::value);
35template<
typename Dest_,
typename Value_>
36constexpr bool check_overflow(Value_ x) {
38 throw std::overflow_error(
"detected " + failure<Dest_>() +
" for integer cast");
58template<
typename Dest_,
typename Value_>
59constexpr Dest_
cast(Value_ x) {
60 check_overflow<Dest_>(x);
Signedness-safe integer comparisons.
Generics for operating on integer representations.
Sanitize sizes to avoid integer overflow.
Definition Bounded.hpp:15
constexpr auto get_value(const Value_ x)
Definition generics.hpp:23
constexpr auto get_max()
Definition generics.hpp:39
constexpr bool can_cast(Value_ x)
Definition cast.hpp:22
constexpr bool is_less_than_or_equal(Left_ left, Right_ right)
Definition comparisons.hpp:75
constexpr Dest_ cast(Value_ x)
Definition cast.hpp:59