1#ifndef SANISIZER_CAP_HPP
2#define SANISIZER_CAP_HPP
29template<
typename Dest_,
typename Value_>
30constexpr Dest_
cap(Value_ x) {
31 static_assert(std::is_integral<Dest_>::value);
32 constexpr auto maxed = std::numeric_limits<Dest_>::max();
33 constexpr auto umaxed = as_unsigned(maxed);
38 }
else if (umaxed >= as_unsigned(val)) {
Create compile-time attestations.
Sanitize sizes to avoid integer overflow.
Definition arithmetic.hpp:16
constexpr auto get_value(Value_ x)
Definition attest.hpp:105
constexpr auto get_max()
Definition attest.hpp:119
constexpr Dest_ cap(Value_ x)
Definition cap.hpp:30