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

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 Thu Oct 8 14:48:51 2015 for LevelS C++ support library