diff --git a/base/mem_trie.hpp b/base/mem_trie.hpp index 53e706fca3..4749c21707 100644 --- a/base/mem_trie.hpp +++ b/base/mem_trie.hpp @@ -61,14 +61,15 @@ private: template struct VectorValues { - template - void Add(V && v) + using value_type = Value; + + template + void Add(Args &&... args) { - m_values.emplace_back(std::forward(v)); + m_values.emplace_back(std::forward(args)...); } - template - void Erase(V const & v) + void Erase(Value const & v) { auto const it = find(m_values.begin(), m_values.end(), v); if (it != m_values.end()) @@ -90,7 +91,7 @@ struct VectorValues // This class is a simple in-memory trie which allows to add // key-value pairs and then traverse them in a sorted order. -template class Moves = MapMoves> +template class Moves = MapMoves> class MemTrie { private: @@ -98,6 +99,7 @@ private: public: using Char = typename String::value_type; + using Value = typename ValuesHolder::value_type; MemTrie() = default; MemTrie(MemTrie && rhs) { *this = std::move(rhs); } @@ -140,8 +142,8 @@ public: }; // Adds a key-value pair to the trie. - template - void Add(String const & key, Value && value) + template + void Add(String const & key, Args &&... args) { auto * cur = &m_root; for (auto const & c : key) @@ -151,10 +153,9 @@ public: if (created) ++m_numNodes; } - cur->Add(std::forward(value)); + cur->Add(std::forward(args)...); } - template void Erase(String const & key, Value const & value) { return Erase(m_root, 0 /* level */, key, value); @@ -215,13 +216,12 @@ private: void EraseMove(Char const & c) { m_moves.EraseSubtree(c); } - template - void Add(Value && value) + template + void Add(Args &&... args) { - m_values.Add(std::forward(value)); + m_values.Add(std::forward(args)...); } - template void EraseValue(Value const & value) { m_values.Erase(value); @@ -236,7 +236,7 @@ private: } Moves m_moves; - Values m_values; + ValuesHolder m_values; DISALLOW_COPY(Node); }; @@ -253,7 +253,6 @@ private: return cur; } - template void Erase(Node & root, size_t level, String const & key, Value const & value) { if (level == key.size()) diff --git a/indexer/search_string_utils.cpp b/indexer/search_string_utils.cpp index 231231f317..37e75e4052 100644 --- a/indexer/search_string_utils.cpp +++ b/indexer/search_string_utils.cpp @@ -143,6 +143,8 @@ class StreetsSynonymsHolder public: struct BooleanSum { + using value_type = bool; + void Add(bool value) { m_value = m_value || value; } template