wibble
1.1
wibble
cast.h
Go to the documentation of this file.
1
// -*- C++ -*-
2
#include <
wibble/exception.h
>
3
#ifndef WIBBLE_CAST_H
4
#define WIBBLE_CAST_H
5
6
namespace
wibble
{
7
8
template
<
typename
T,
typename
X> T &
downcast
(
X
*
v
) {
9
if
(!
v
)
10
throw
exception::BadCastExt< X, T >
(
"downcast on null pointer"
);
11
T *x =
dynamic_cast<
T *
>
(
v
);
12
if
(!x)
13
throw
exception::BadCastExt< X, T >
(
"dynamic downcast failed"
);
14
return
*x;
15
}
16
17
template
<
typename
T >
18
typename
T::WrappedType &
unwrap
(
const
T &x ) {
19
return
x.unwrap();
20
}
21
22
template
<
typename
T >
23
T &
unwrap
( T &x ) {
return
x; }
24
25
template
<
typename
_T,
typename
In >
struct
IsType
{
26
typedef
_T
T
;
27
};
28
29
}
30
31
#endif
exception.h
wibble
Definition
amorph.h:17
wibble::unwrap
T::WrappedType & unwrap(const T &x)
Definition
cast.h:18
wibble::downcast
X::template Convert< T >::type & downcast(const X &a)
Definition
amorph.h:413
wibble::IsType
Definition
cast.h:25
wibble::IsType::T
_T T
Definition
cast.h:26
wibble::SanitizeReturn
Definition
amorph.h:30
wibble::exception::BadCastExt
Definition
exception.h:288
Generated by
1.9.8