simplify templates for operators, add more checks
This commit is contained in:
parent
cd28d872e7
commit
f574d7e084
1 changed files with 11 additions and 18 deletions
|
@ -66,12 +66,7 @@ class alt_string
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename op_type>
|
template <typename op_type>
|
||||||
typename std::enable_if< // disable for alt_string
|
bool operator==(const op_type& op) const
|
||||||
!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;
|
||||||
}
|
}
|
||||||
|
@ -82,12 +77,7 @@ class alt_string
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename op_type>
|
template <typename op_type>
|
||||||
typename std::enable_if< // disable for alt_string
|
bool operator!=(const op_type& op) const
|
||||||
!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;
|
||||||
}
|
}
|
||||||
|
@ -112,12 +102,7 @@ class alt_string
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename op_type>
|
template <typename op_type>
|
||||||
typename std::enable_if< // disable for alt_string
|
bool operator<(const op_type& op) const
|
||||||
!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;
|
||||||
}
|
}
|
||||||
|
@ -255,18 +240,26 @@ TEST_CASE("alternative string type")
|
||||||
|
|
||||||
CHECK("I'm Batman" == doc["Who are you?"]);
|
CHECK("I'm Batman" == doc["Who are you?"]);
|
||||||
CHECK(doc["Who are you?"] == "I'm Batman");
|
CHECK(doc["Who are you?"] == "I'm Batman");
|
||||||
|
CHECK_FALSE("I'm Batman" != doc["Who are you?"]);
|
||||||
|
CHECK_FALSE(doc["Who are you?"] != "I'm Batman");
|
||||||
|
|
||||||
CHECK("I'm Bruce Wayne" != doc["Who are you?"]);
|
CHECK("I'm Bruce Wayne" != doc["Who are you?"]);
|
||||||
CHECK(doc["Who are you?"] != "I'm Bruce Wayne");
|
CHECK(doc["Who are you?"] != "I'm Bruce Wayne");
|
||||||
|
CHECK_FALSE("I'm Bruce Wayne" == doc["Who are you?"]);
|
||||||
|
CHECK_FALSE(doc["Who are you?"] == "I'm Bruce Wayne");
|
||||||
|
|
||||||
{
|
{
|
||||||
const alt_json& const_doc = doc;
|
const alt_json& const_doc = doc;
|
||||||
|
|
||||||
CHECK("I'm Batman" == const_doc["Who are you?"]);
|
CHECK("I'm Batman" == const_doc["Who are you?"]);
|
||||||
CHECK(const_doc["Who are you?"] == "I'm Batman");
|
CHECK(const_doc["Who are you?"] == "I'm Batman");
|
||||||
|
CHECK_FALSE("I'm Batman" != const_doc["Who are you?"]);
|
||||||
|
CHECK_FALSE(const_doc["Who are you?"] != "I'm Batman");
|
||||||
|
|
||||||
CHECK("I'm Bruce Wayne" != const_doc["Who are you?"]);
|
CHECK("I'm Bruce Wayne" != const_doc["Who are you?"]);
|
||||||
CHECK(const_doc["Who are you?"] != "I'm Bruce Wayne");
|
CHECK(const_doc["Who are you?"] != "I'm Bruce Wayne");
|
||||||
|
CHECK_FALSE("I'm Bruce Wayne" == const_doc["Who are you?"]);
|
||||||
|
CHECK_FALSE(const_doc["Who are you?"] == "I'm Bruce Wayne");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue