#include <limits>
#include <type_traits>
#include <utility>
#include <stdexcept>
Go to the source code of this file.
|
| template<typename TType , typename SType > |
| TType | unsigned2signed (SType &&source_value) |
| | convert unsigned to signed integers
|
| |
| template<typename TType , typename SType > |
| TType | signed2unsigned (SType &&source_value) |
| |
◆ signed2unsigned()
template<typename TType , typename SType >
| TType signed2unsigned |
( |
SType && |
source_value | ) |
|
◆ unsigned2signed()
template<typename TType , typename SType >
| TType unsigned2signed |
( |
SType && |
source_value | ) |
|
This operation shows up quite often in the library and causes warnings for virtually all compilers. This template function tries to provide a clean implementation of such a conversion and throws an error if it would fail.
Compile time errors are produced if the types are
- Template Parameters
-
| TType | the unsigned source type |
| SType | signed target type |
- Parameters
-
| source_value | universal reference to the unsigned source value |
- Returns
- new instance of TType
- Exceptions
-
| std::range_error | if the source value does not fit into the positive range of the target signed integer |