From 9ac59f5f26c8b8c01e127249d71798a99f756df8 Mon Sep 17 00:00:00 2001 From: Adrian Kummerländer Date: Fri, 7 Feb 2014 19:32:17 +0100 Subject: Added get member method overload * moves optional-checking functionality from recursive get-by-path into a method returning its instance's value --- src/trie.h | 16 +++++++++------- 1 file 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 get() { + if ( this->value_.first ) { + return detail::optional_ptr(&this->value_.second); + } else { + return detail::optional_ptr(); + } + } + inline detail::optional_ptr get(key_list path) { if ( auto tmp = this->resolve(path) ) { - if ( tmp.get()->value_.first ) { - return detail::optional_ptr( - &tmp.get()->value_.second - ); - } else { - return detail::optional_ptr(); - } + return tmp.get()->get(); } else { return detail::optional_ptr(); } -- cgit v1.2.3