Added concept HasIndexOperator

This commit is contained in:
Maksim Kita 2021-10-15 23:26:09 +03:00
parent a744097fb6
commit a35d7096d8

View File

@ -58,12 +58,11 @@ namespace ErrorCodes
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
}
template <class T, class = void>
struct HasIndexOperator : std::false_type {};
template <class T>
struct HasIndexOperator<T, std::void_t<decltype(std::declval<T>()[0])>> : std::true_type {};
template <typename T>
concept HasIndexOperator = requires (T t)
{
t[0];
};
/// Functions to parse JSONs and extract values from it.
/// The first argument of all these functions gets a JSON,
@ -285,7 +284,7 @@ private:
return true;
}
if constexpr (HasIndexOperator<typename JSONParser::Object>::value)
if constexpr (HasIndexOperator<typename JSONParser::Object>)
{
if (element.isObject())
{