LevelS C++ support library  3.83
Functions
safe_cast.h File Reference
#include <limits>
#include "error_handling.h"

Go to the source code of this file.

Functions

template<typename T1 , typename T2 >
T1 safe_cast (const T2 &arg)
 

Detailed Description

Numerical cast operator with additional checks that the value is preserved.

Copyright (C) 2009 Max-Planck-Society Author: Martin Reinecke

Definition in file safe_cast.h.

Function Documentation

◆ safe_cast()

template<typename T1 , typename T2 >
T1 safe_cast ( const T2 &  arg)
inline

Tries to cast arg from its type to a variable of type T1. If this conversion leads to a change of the actual value (e.g. due to overflow or truncation), an exception is thrown.

Definition at line 86 of file safe_cast.h.


Generated on Wed Nov 13 2024 12:18:16 for LevelS C++ support library