mirror of
https://github.com/nlohmann/json.git
synced 2025-07-28 12:02:00 +03:00
define global operator< for const char* and alt_string
This commit is contained in:
@ -106,7 +106,12 @@ class alt_string
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename op_type>
|
template <typename op_type>
|
||||||
bool operator<(op_type&& op) const
|
typename std::enable_if< // disable for alt_string
|
||||||
|
!std::is_same< alt_string,
|
||||||
|
typename std::remove_reference<op_type>::type
|
||||||
|
>::value,
|
||||||
|
bool>::type
|
||||||
|
operator<(op_type&& op) const
|
||||||
{
|
{
|
||||||
return str_impl < op;
|
return str_impl < op;
|
||||||
}
|
}
|
||||||
@ -153,6 +158,8 @@ class alt_string
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::string str_impl;
|
std::string str_impl;
|
||||||
|
|
||||||
|
friend bool ::operator<(const char*, const alt_string&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -168,6 +175,11 @@ using alt_json = nlohmann::basic_json <
|
|||||||
nlohmann::adl_serializer >;
|
nlohmann::adl_serializer >;
|
||||||
|
|
||||||
|
|
||||||
|
bool operator<(const char* op1, const alt_string& op2) {
|
||||||
|
return op1 < op2.str_impl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("alternative string type")
|
TEST_CASE("alternative string type")
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user