diff options
author | Adrian Kummerländer | 2014-02-07 19:32:17 +0100 |
---|---|---|
committer | Adrian Kummerländer | 2014-02-07 19:32:17 +0100 |
commit | 9ac59f5f26c8b8c01e127249d71798a99f756df8 (patch) | |
tree | 9bf011908b25291fd7e82169eeba0f6a56f4c7df | |
parent | 74935056c496814a3c9d1380437812536b159203 (diff) | |
download | Trie-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.h | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -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>(); } |