sanisizer
Sanitize sizes to avoid integer overflow
Loading...
Searching...
No Matches
sanisizer::Exact< Integer_ > Class Template Reference

Do not cast an integer in a function call. More...

#include <class.hpp>

Public Member Functions

constexpr Exact (Integer_ x)
 
constexpr operator Integer_ () const
 
template<typename Output_ >
constexpr operator Output_ () const =delete
 

Detailed Description

template<typename Integer_>
class sanisizer::Exact< Integer_ >

Do not cast an integer in a function call.

Template Parameters
Integer_Type of the integer used in the call.

Consider a function f(T x) for some (non-template) integer T. When calling this function on an integer y, we can use f(Exact(y)), which will throw a compile-time error if the type of y is not T.

Constructor & Destructor Documentation

◆ Exact()

template<typename Integer_ >
sanisizer::Exact< Integer_ >::Exact ( Integer_ x)
inlineconstexpr
Parameters
xInteger value.

Member Function Documentation

◆ operator Integer_()

template<typename Integer_ >
sanisizer::Exact< Integer_ >::operator Integer_ ( ) const
inlineconstexpr
Returns
x as an Integer_.

◆ operator Output_()

template<typename Integer_ >
template<typename Output_ >
sanisizer::Exact< Integer_ >::operator Output_ ( ) const
constexprdelete
Template Parameters
Output_Type of the integer to be casted to.

This is deleted so any attempt at a conversion will result in a compile-time error.


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