sanisizer
Sanitize sizes to avoid integer overflow
Loading...
Searching...
No Matches
Constant.hpp
Go to the documentation of this file.
1#ifndef SANISIZER_CONSTANT_HPP
2#define SANISIZER_CONSTANT_HPP
3
4#include <type_traits>
5
11namespace sanisizer {
12
23template<typename Integer_, Integer_ value_>
24struct Constant {
25 static_assert(std::is_integral<Integer_>::value);
26 static_assert(value_ >= 0);
27
31 typedef Integer_ Integer;
32
37 static constexpr Integer_ value = value_;
38};
39
45template<typename Value_>
50 static constexpr bool value = false;
51};
52
59template<typename Integer_, Integer_ value_>
60struct is_Constant<Constant<Integer_, value_> > {
64 static constexpr bool value = true;
65};
66
70template<typename Integer_, Integer_ value_>
71struct is_Constant<const Constant<Integer_, value_> > {
72 static constexpr bool value = true;
73};
78}
79
80#endif
Sanitize sizes to avoid integer overflow.
Definition Bounded.hpp:15
Integer constant.
Definition Constant.hpp:24
Integer_ Integer
Definition Constant.hpp:31
static constexpr Integer_ value
Definition Constant.hpp:37
Definition Constant.hpp:46
static constexpr bool value
Definition Constant.hpp:50