Basic functionality and interfaces This package is system independent.
template<class T , class U >
| constexpr T imtbase::narrow_cast |
( |
U |
v | ) |
|
|
constexprnoexcept |
This is a similar implementation from the Guidelines Support Library (GSL), which is used deliberately for explicit type narrowing.
Meaning "I know thatthere is a narrowing here, and I take responsibility for myself" Makes a clear narrowing DOES NOT check for overflow (in release mode) Just a static_cast, but semantically expressive
- Note
- Use it carefully. Only for old code or 3rd party functions which can't be changed
QList<int> list;
int numberOfElements = list.size();
int iNumberOfElements = narrow_cast<int>(list.size());
Definition at line 35 of file imtbase.h.