aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-02-07 19:32:17 +0100
committerAdrian Kummerländer2014-02-07 19:32:17 +0100
commit9ac59f5f26c8b8c01e127249d71798a99f756df8 (patch)
tree9bf011908b25291fd7e82169eeba0f6a56f4c7df
parent74935056c496814a3c9d1380437812536b159203 (diff)
downloadTrie-9ac59f5f26c8b8c01e127249d71798a99f756df8.tar
Trie-9ac59f5f26c8b8c01e127249d71798a99f756df8.tar.gz
Trie-9ac59f5f26c8b8c01e127249d71798a99f756df8.tar.bz2
Trie-9ac59f5f26c8b8c01e127249d71798a99f756df8.tar.lz
Trie-9ac59f5f26c8b8c01e127249d71798a99f756df8.tar.xz
Trie-9ac59f5f26c8b8c01e127249d71798a99f756df8.tar.zst
Trie-9ac59f5f26c8b8c01e127249d71798a99f756df8.zip
Added get member method overload
* moves optional-checking functionality from recursive get-by-path into a method returning its instance's value
-rw-r--r--src/trie.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/trie.h b/src/trie.h
index 6262ab3..b31900f 100644
--- a/src/trie.h
+++ b/src/trie.h
@@ -39,15 +39,17 @@ class Trie {
return this->resolve(path);
}
+ inline detail::optional_ptr<Value> get() {
+ if ( this->value_.first ) {
+ return detail::optional_ptr<Value>(&this->value_.second);
+ } else {
+ return detail::optional_ptr<Value>();
+ }
+ }
+
inline detail::optional_ptr<Value> get(key_list path) {
if ( auto tmp = this->resolve(path) ) {
- if ( tmp.get()->value_.first ) {
- return detail::optional_ptr<Value>(
- &tmp.get()->value_.second
- );
- } else {
- return detail::optional_ptr<Value>();
- }
+ return tmp.get()->get();
} else {
return detail::optional_ptr<Value>();
}