diff options
author | Adrian Kummerländer | 2014-02-06 20:26:45 +0100 |
---|---|---|
committer | Adrian Kummerländer | 2014-02-06 20:26:45 +0100 |
commit | 13f079c5150d86bb87b71094e545e720e245658d (patch) | |
tree | d0c0edc44f3bcd30b50cd947868011a0108bd7e5 /src/utility.h | |
parent | 35f814706c4ff244bc15c4285804fc0656824c41 (diff) | |
download | Trie-13f079c5150d86bb87b71094e545e720e245658d.tar Trie-13f079c5150d86bb87b71094e545e720e245658d.tar.gz Trie-13f079c5150d86bb87b71094e545e720e245658d.tar.bz2 Trie-13f079c5150d86bb87b71094e545e720e245658d.tar.lz Trie-13f079c5150d86bb87b71094e545e720e245658d.tar.xz Trie-13f079c5150d86bb87b71094e545e720e245658d.tar.zst Trie-13f079c5150d86bb87b71094e545e720e245658d.zip |
Introduced simple result wrapper template
* offers bool() operator for easy assignment checks inside conditional statements
Diffstat (limited to 'src/utility.h')
-rw-r--r-- | src/utility.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/utility.h b/src/utility.h new file mode 100644 index 0000000..6342420 --- /dev/null +++ b/src/utility.h @@ -0,0 +1,29 @@ +#ifndef TRIE_SRC_UTILITY_H_ +#define TRIE_SRC_UTILITY_H_ + +namespace detail { + +template < + typename Value +> +struct Result { + Result(): + value_(false, Value()) { } + + Result(Value value): + value_(true, value) { } + + inline operator bool() const { + return this->value_.first; + } + + inline Value get() const { + return this->value_.second; + } + + const std::pair<bool, Value> value_; +}; + +} + +#endif // TRIE_SRC_UTILITY_H_ |