mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-08 20:10:04 -04:00
Allow comparison with string_view and converted to
Using identity of trick, the template argument is only deduced on the first (or the second) argument and therefore allows implicit conversion for one of them.
This commit is contained in:
parent
5388d9ee12
commit
28b6076147
@ -180,6 +180,10 @@ static_assert(sizeof(string_view) == 16, "The size of a string_view must always
|
||||
|
||||
// TODO Switch to C++14 and use constexpr for these functions
|
||||
|
||||
// Note: The identity_of_t trick is simply to ensure that template argument
|
||||
// deduction is only done on one of the two arguments. This is allowing implicit
|
||||
// conversion (string and string_view for instance)
|
||||
|
||||
// non-member comparison functions
|
||||
|
||||
template <typename CharT>
|
||||
@ -187,31 +191,91 @@ bool operator==(basic_string_view<CharT> x, basic_string_view<CharT> y) noexcept
|
||||
return x.compare(y) == 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator==(basic_string_view<CharT> x, std::identity_of_t<basic_string_view<CharT>> y) noexcept {
|
||||
return x.compare(y) == 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator==(std::identity_of_t<basic_string_view<CharT>> x, basic_string_view<CharT> y) noexcept {
|
||||
return x.compare(y) == 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator!=(basic_string_view<CharT> x, basic_string_view<CharT> y) noexcept {
|
||||
return x.compare(y) != 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator!=(std::identity_of_t<basic_string_view<CharT>> x, basic_string_view<CharT> y) noexcept {
|
||||
return x.compare(y) != 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator!=(basic_string_view<CharT> x, std::identity_of_t<basic_string_view<CharT>> y) noexcept {
|
||||
return x.compare(y) != 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator<(basic_string_view<CharT> x, basic_string_view<CharT> y) noexcept {
|
||||
return x.compare(y) < 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator<(std::identity_of_t<basic_string_view<CharT>> x, basic_string_view<CharT> y) noexcept {
|
||||
return x.compare(y) < 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator<(basic_string_view<CharT> x, std::identity_of_t<basic_string_view<CharT>> y) noexcept {
|
||||
return x.compare(y) < 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator>(basic_string_view<CharT> x, basic_string_view<CharT> y) noexcept {
|
||||
return x.compare(y) > 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator>(std::identity_of_t<basic_string_view<CharT>> x, basic_string_view<CharT> y) noexcept {
|
||||
return x.compare(y) > 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator>(basic_string_view<CharT> x, std::identity_of_t<basic_string_view<CharT>> y) noexcept {
|
||||
return x.compare(y) > 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator<=(basic_string_view<CharT> x, basic_string_view<CharT> y) noexcept {
|
||||
return x.compare(y) <= 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator<=(std::identity_of_t<basic_string_view<CharT>> x, basic_string_view<CharT> y) noexcept {
|
||||
return x.compare(y) <= 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator<=(basic_string_view<CharT> x, std::identity_of_t<basic_string_view<CharT>> y) noexcept {
|
||||
return x.compare(y) <= 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator>=(basic_string_view<CharT> x, basic_string_view<CharT> y) noexcept {
|
||||
return x.compare(y) >= 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator>=(std::identity_of_t<basic_string_view<CharT>> x, basic_string_view<CharT> y) noexcept {
|
||||
return x.compare(y) >= 0;
|
||||
}
|
||||
|
||||
template <typename CharT>
|
||||
bool operator>=(basic_string_view<CharT> x, std::identity_of_t<basic_string_view<CharT>> y) noexcept {
|
||||
return x.compare(y) >= 0;
|
||||
}
|
||||
|
||||
} //end of namespace std
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user