blob: 6af6b6ae4c07346b98647e8ff49750b2d7033b36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#ifndef TRIE_SRC_UTILITY_H_
#define TRIE_SRC_UTILITY_H_
namespace detail {
template <
typename Type
>
class optional_ptr {
public:
typedef typename std::add_pointer<Type>::type pointer;
typedef Type element_type;
optional_ptr():
value_(false, nullptr) { }
optional_ptr(pointer ptr):
value_(true, ptr) { }
operator bool() const {
return this->value_.first;
}
pointer get() const {
return this->value_.second;
}
private:
const std::pair<bool, pointer> value_;
};
}
#endif // TRIE_SRC_UTILITY_H_
|