aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/CStringView.h
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-10-03 15:52:29 -0700
committerRobert Schumacher <roschuma@microsoft.com>2017-10-03 15:52:29 -0700
commitd5705e87c42784607bf462159bebe14044a88eca (patch)
treeaded4a5806480ad3e6980b8c5f4dacd61a004614 /toolsrc/include/CStringView.h
parentc167c70c272a417779e601fffcbdb72278da1848 (diff)
parent3838d5880470fdc884f035ed3d1c67d3bdd1e16e (diff)
downloadvcpkg-d5705e87c42784607bf462159bebe14044a88eca.tar.gz
vcpkg-d5705e87c42784607bf462159bebe14044a88eca.zip
Merge branch 'master' into martin-s-patch-vs2013
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)
{