aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/CStringView.h
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/include/CStringView.h')
-rw-r--r--toolsrc/include/CStringView.h44
1 files changed, 43 insertions, 1 deletions
diff --git a/toolsrc/include/CStringView.h b/toolsrc/include/CStringView.h
index 282caad3a..c1810b4f1 100644
--- a/toolsrc/include/CStringView.h
+++ b/toolsrc/include/CStringView.h
@@ -11,13 +11,36 @@ namespace vcpkg
constexpr BasicCStringView(const BasicCStringView&) = default;
BasicCStringView(const std::basic_string<CharType>& str) : cstr(str.c_str()) {}
- constexpr operator const CharType*() const { return cstr; }
constexpr const CharType* c_str() const { return cstr; }
private:
const CharType* cstr;
};
+ namespace details
+ {
+ inline bool vcpkg_strcmp(const char* l, const char* r) { return strcmp(l, r) == 0; }
+ inline bool vcpkg_strcmp(const wchar_t* l, const wchar_t* r) { return wcscmp(l, r) == 0; }
+ }
+
+ template<class CharType>
+ bool operator==(const BasicCStringView<CharType>& l, const BasicCStringView<CharType>& r)
+ {
+ return details::vcpkg_strcmp(l.c_str(), r.c_str());
+ }
+
+ template<class CharType>
+ bool operator==(const CharType* l, const BasicCStringView<CharType>& r)
+ {
+ return details::vcpkg_strcmp(l, r.c_str());
+ }
+
+ template<class CharType>
+ bool operator==(const BasicCStringView<CharType>& r, const CharType* l)
+ {
+ return details::vcpkg_strcmp(l, r.c_str());
+ }
+
template<class CharType>
bool operator==(const std::basic_string<CharType>& l, const BasicCStringView<CharType>& r)
{
@@ -30,6 +53,25 @@ namespace vcpkg
return l == r.c_str();
}
+ // notequals
+ template<class CharType>
+ bool operator!=(const BasicCStringView<CharType>& l, const BasicCStringView<CharType>& r)
+ {
+ return !details::vcpkg_strcmp(l.c_str(), r.c_str());
+ }
+
+ template<class CharType>
+ bool operator!=(const CharType* l, const BasicCStringView<CharType>& r)
+ {
+ return !details::vcpkg_strcmp(l, r.c_str());
+ }
+
+ template<class CharType>
+ bool operator!=(const BasicCStringView<CharType>& r, const CharType* l)
+ {
+ return !details::vcpkg_strcmp(l, r.c_str());
+ }
+
template<class CharType>
bool operator!=(const BasicCStringView<CharType>& r, const std::basic_string<CharType>& l)
{