Add known_cast to type casts
This commit is contained in:
parent
8c5dd1eea1
commit
481f55a9c4
@ -117,4 +117,21 @@ size_cast (const V v) {
|
|||||||
return static_cast<T> (v);
|
return static_cast<T> (v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
template <typename T, typename V>
|
||||||
|
T*
|
||||||
|
known_cast (V *v) {
|
||||||
|
CHECK_HARD (nullptr != dynamic_cast<T> (v));
|
||||||
|
return static_cast<T> (v);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T, typename V>
|
||||||
|
T&
|
||||||
|
known_cast (V &v) {
|
||||||
|
CHECK_NOTHROW (dynamic_cast<T> (v));
|
||||||
|
return static_cast<T> (v);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user