support types convertible to string_view as JSON keys (#4958)

Signed-off-by: khloodelhossiny <khloood.elhossiny@gmail.com>
Co-authored-by: khloodelhossiny <khloood.elhossiny@gmail.com>
This commit is contained in:
KhloodElhossiny
2026-01-11 22:45:22 +02:00
committed by GitHub
parent 515d994acb
commit 8f75700141
3 changed files with 68 additions and 10 deletions

View File

@@ -636,11 +636,14 @@ using is_usable_as_key_type = typename std::conditional <
template<typename BasicJsonType, typename KeyTypeCVRef, bool RequireTransparentComparator = true,
bool ExcludeObjectKeyType = RequireTransparentComparator, typename KeyType = uncvref_t<KeyTypeCVRef>>
using is_usable_as_basic_json_key_type = typename std::conditional <
is_usable_as_key_type<typename BasicJsonType::object_comparator_t,
typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
RequireTransparentComparator, ExcludeObjectKeyType>::value
&& !is_json_iterator_of<BasicJsonType, KeyType>::value,
std::true_type,
(is_usable_as_key_type<typename BasicJsonType::object_comparator_t,
typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
RequireTransparentComparator, ExcludeObjectKeyType>::value
&& !is_json_iterator_of<BasicJsonType, KeyType>::value)
#ifdef JSON_HAS_CPP_17
|| std::is_convertible<KeyType, std::string_view>::value
#endif
, std::true_type,
std::false_type >::type;
template<typename ObjectType, typename KeyType>