cast: style
This commit is contained in:
parent
e05e049c69
commit
0be5ccf5c7
8
cast.hpp
8
cast.hpp
@ -98,13 +98,14 @@ trunc_cast (U u)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///----------------------------------------------------------------------------
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
/// assert if the value is not a pointer to a subclass of T, else return the
|
/// assert if the value is not a pointer to a subclass of T, else return the
|
||||||
/// converted value. Note: this is only a debug-time check and is compiled out
|
/// converted value. Note: this is only a debug-time check and is compiled out
|
||||||
/// in optimised builds.
|
/// in optimised builds.
|
||||||
template <typename T, typename V>
|
template <typename T, typename V>
|
||||||
T*
|
T*
|
||||||
known_cast (V *v) {
|
known_cast (V *v)
|
||||||
|
{
|
||||||
CHECK (dynamic_cast<T*> (v));
|
CHECK (dynamic_cast<T*> (v));
|
||||||
return static_cast<T*> (v);
|
return static_cast<T*> (v);
|
||||||
}
|
}
|
||||||
@ -113,7 +114,8 @@ known_cast (V *v) {
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T, typename V>
|
template <typename T, typename V>
|
||||||
T&
|
T&
|
||||||
known_cast (V &v) {
|
known_cast (V &v)
|
||||||
|
{
|
||||||
CHECK_NOTHROW (dynamic_cast<T> (v));
|
CHECK_NOTHROW (dynamic_cast<T> (v));
|
||||||
return static_cast<T> (v);
|
return static_cast<T> (v);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user