wibble
1.1
Main Page
Namespaces
Classes
Files
File List
File Members
wibble
fallback.h
Go to the documentation of this file.
1
6
#include <
wibble/exception.h
>
7
8
#ifndef WIBBLE_FALLBACK_H
9
#define WIBBLE_FALLBACK_H
10
11
namespace
wibble {
12
13
struct
Error
{};
14
15
template
<
typename
T >
16
struct
Fallback
{
17
const
T *
value
;
18
Fallback
(
const
T &v ) :
value
( &v ) {}
19
Fallback
(
Error
=
Error
() ) :
value
( 0 ) {}
20
21
template
<
typename
E >
const
T &
get
(
const
E &e ) {
22
if
( !
value
)
throw
e;
23
return
*
value
;
24
}
25
26
const
T &
get
() {
27
if
( !
value
)
throw
exception::Consistency
(
"tried to use undefined fallback value"
);
28
return
*
value
;
29
}
30
};
31
32
}
33
34
#endif
Generated on Wed Oct 23 2013 17:14:25 for wibble by
1.8.4