88#include < iris/ngram/database.hpp>
99#include < iris/ngram/id.hpp>
1010
11- #include < iris/hash.hpp>
12-
11+ #include < format>
1312#include < unordered_map>
1413#include < stdexcept>
1514#include < memory>
@@ -25,7 +24,7 @@ class keyed_database : private database<CharT>
2524public:
2625 using document_id_type = KeyT;
2726
28- template <class KeyLikeT >
27+ template <class KeyLikeT = KeyT >
2928 requires std::is_constructible_v<KeyT, KeyLikeT>
3029 void add_document (KeyLikeT&& key_like, std::basic_string_view<CharT> const doc_text)
3130 {
@@ -34,8 +33,10 @@ class keyed_database : private database<CharT>
3433 if (!inserted) {
3534 if constexpr (std::is_pointer_v<KeyT>) {
3635 throwf<std::invalid_argument>(" key `{}` already exists in keyed_database" , static_cast <void const *>(it->first ));
37- } else {
36+ } else if constexpr (std::formattable<KeyT, char >) {
3837 throwf<std::invalid_argument>(" key `{}` already exists in keyed_database" , it->first );
38+ } else {
39+ throwf<std::invalid_argument>(" key `???` already exists in keyed_database" );
3940 }
4041 }
4142 assert (doc_id_to_key_.size () == detail::to_index (doc_id));
@@ -48,7 +49,7 @@ class keyed_database : private database<CharT>
4849 base_type::update_document (this ->get_document_id (key_like), doc_text);
4950 }
5051
51- template <class KeyLikeT >
52+ template <class KeyLikeT = KeyT >
5253 requires std::is_constructible_v<KeyT, KeyLikeT>
5354 void add_or_update_document (KeyLikeT&& key_like, std::basic_string_view<CharT> const doc_text)
5455 {
0 commit comments