#include <type_traits>
#include "invariant.h"
Go to the source code of this file.
◆ narrow()
Run-time checked narrowing cast.
Raises an invariant if the input value cannot be converted to the output value without data loss
Template accepts a single argument - the return type. Input type is deduced from the function argument and shouldn't be specified
Definition at line 34 of file narrow.h.
◆ narrow_cast()
Alias for static_cast intended to be used for numeric casting Rationale: Easier to grep than static_cast.
Definition at line 19 of file narrow.h.
◆ narrow_or_throw_out_of_range()
Run-time checked narrow cast.
Throws a std::out_of_range error if the input cannot be converted to the output_type without data lass
Definition at line 44 of file narrow.h.