diff --git a/include/iris/ngram/database.hpp b/include/iris/ngram/database.hpp index 6ada138..34add63 100644 --- a/include/iris/ngram/database.hpp +++ b/include/iris/ngram/database.hpp @@ -74,8 +74,8 @@ class database store_.clear(); } - template - bool search(this auto const& db, search_query const& query, search_result& search_res) + template + bool search(this auto const& db, search_query const& query, search_result& search_res) { search_res.clear(); if (query.empty()) return false; diff --git a/include/iris/ngram/keyed_database.hpp b/include/iris/ngram/keyed_database.hpp index 8d0334b..37fb17c 100644 --- a/include/iris/ngram/keyed_database.hpp +++ b/include/iris/ngram/keyed_database.hpp @@ -8,8 +8,7 @@ #include #include -#include - +#include #include #include #include @@ -25,7 +24,7 @@ class keyed_database : private database public: using document_id_type = KeyT; - template + template requires std::is_constructible_v void add_document(KeyLikeT&& key_like, std::basic_string_view const doc_text) { @@ -34,8 +33,10 @@ class keyed_database : private database if (!inserted) { if constexpr (std::is_pointer_v) { throwf("key `{}` already exists in keyed_database", static_cast(it->first)); - } else { + } else if constexpr (std::formattable) { throwf("key `{}` already exists in keyed_database", it->first); + } else { + throwf("key `???` already exists in keyed_database"); } } assert(doc_id_to_key_.size() == detail::to_index(doc_id)); @@ -48,7 +49,7 @@ class keyed_database : private database base_type::update_document(this->get_document_id(key_like), doc_text); } - template + template requires std::is_constructible_v void add_or_update_document(KeyLikeT&& key_like, std::basic_string_view const doc_text) { diff --git a/include/iris/ngram/search_result.hpp b/include/iris/ngram/search_result.hpp index 7e39c5f..98fc639 100644 --- a/include/iris/ngram/search_result.hpp +++ b/include/iris/ngram/search_result.hpp @@ -59,11 +59,13 @@ struct [[nodiscard]] search_word_match std::vector> spans_; }; -template +template, class EqualT = std::equal_to<>> struct [[nodiscard]] search_result { using document_id_type = DocumentID; - using map_type = std::unordered_map>; + using hash_type = HashT; + using equal_type = EqualT; + using map_type = std::unordered_map, HashT, EqualT>; search_result() = default;