Skip to content

Instantly share code, notes, and snippets.

@vinniefalco
Created November 14, 2019 19:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vinniefalco/7cc09cfb41460e8cc70bf9ec34202d5e to your computer and use it in GitHub Desktop.
/** Return true if two values are equal.
A lexicographical comparison is performed
to determine if the two strings are equal.
*/
template<class T
, class = typename std::enable_if<
std::is_convertible<
T const&, string_view>::value
>::type
>
bool
operator==(string const& lhs, T const& rhs) noexcept
{
return string_view(lhs) == string_view(rhs);
}
/** Return true if two values are equal.
A lexicographical comparison is performed
to determine if the two strings are equal.
*/
template<class T
#ifndef GENERATING_DOCUMENTATION
, class = typename std::enable_if<
std::is_convertible<
T const&, string_view>::value &&
! std::is_base_of<string, T>::value
>::type
#endif
>
bool operator==(T const& lhs, string const& rhs) noexcept
{
return string_view(lhs) == string_view(rhs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment