sanisizer
Sanitize sizes to avoid integer overflow
Loading...
Searching...
No Matches
sanisizer::Bounded< Integer_, max_ > Struct Template Reference

Bound the maximum possible value of an integer. More...

#include <Bounded.hpp>

Public Types

typedef Integer_ Integer
 

Public Member Functions

constexpr Bounded (Integer_ x)
 

Public Attributes

Integer_ value
 

Static Public Attributes

static constexpr Integer_ max = max_
 

Detailed Description

template<typename Integer_, Integer_ max_>
struct sanisizer::Bounded< Integer_, max_ >

Bound the maximum possible value of an integer.

Template Parameters
Integer_Type of the integer.
max_Maximum value of the integer, known at compile time. This should be non-negative.

Specifies that an integer has a maximum upper bound of max_, known at compile-time. The upper bound may be less than the maxium value of Integer_, which enables some optimizations in functions like sum() and product(). For example, we could attest that a std::size_t has a upper limit of max_ = 2^31 - 1.

Member Typedef Documentation

◆ Integer

template<typename Integer_ , Integer_ max_>
Integer_ sanisizer::Bounded< Integer_, max_ >::Integer

Type of the integer.

Constructor & Destructor Documentation

◆ Bounded()

template<typename Integer_ , Integer_ max_>
sanisizer::Bounded< Integer_, max_ >::Bounded ( Integer_ x)
inlineconstexpr
Parameters
xValue of the integer. This should be no greater than max_.

Member Data Documentation

◆ max

template<typename Integer_ , Integer_ max_>
Integer_ sanisizer::Bounded< Integer_, max_ >::max = max_
staticconstexpr

Maximum value of the integer, known at compile time. This will be non-negative.

◆ value

template<typename Integer_ , Integer_ max_>
Integer_ sanisizer::Bounded< Integer_, max_ >::value

Value of the integer.


The documentation for this struct was generated from the following file: