diff options
| author | Alexander Saprykin <xelfium@gmail.com> | 2018-05-26 13:27:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-26 13:27:14 +0200 |
| commit | 4ce5f064282c3a8d8d710aa82af7aa346b0c6dd5 (patch) | |
| tree | d95c9490352eb73f078d34a33bc4bb44ac9fa48b /toolsrc/include/CStringView.h | |
| parent | fb689bd13dd6ba563a885d71fff1dd2b32a615db (diff) | |
| parent | 2ac7527b40b1dbeb7856b9f763362c1e139e2ca9 (diff) | |
| download | vcpkg-4ce5f064282c3a8d8d710aa82af7aa346b0c6dd5.tar.gz vcpkg-4ce5f064282c3a8d8d710aa82af7aa346b0c6dd5.zip | |
Merge pull request #1 from Microsoft/master
Update vcpkg from upstream
Diffstat (limited to 'toolsrc/include/CStringView.h')
| -rw-r--r-- | toolsrc/include/CStringView.h | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/toolsrc/include/CStringView.h b/toolsrc/include/CStringView.h deleted file mode 100644 index 282caad3a..000000000 --- a/toolsrc/include/CStringView.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once -#include <string> - -namespace vcpkg -{ - template<class CharType> - struct BasicCStringView - { - constexpr BasicCStringView() : cstr(nullptr) {} - constexpr BasicCStringView(const CharType* cstr) : cstr(cstr) {} - 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; - }; - - template<class CharType> - bool operator==(const std::basic_string<CharType>& l, const BasicCStringView<CharType>& r) - { - return l == r.c_str(); - } - - template<class CharType> - bool operator==(const BasicCStringView<CharType>& r, const std::basic_string<CharType>& l) - { - return l == r.c_str(); - } - - template<class CharType> - bool operator!=(const BasicCStringView<CharType>& r, const std::basic_string<CharType>& l) - { - return l != r.c_str(); - } - - template<class CharType> - bool operator!=(const std::basic_string<CharType>& l, const BasicCStringView<CharType>& r) - { - return l != r.c_str(); - } - - using CStringView = BasicCStringView<char>; - using CWStringView = BasicCStringView<wchar_t>; - - inline const char* to_printf_arg(const CStringView string_view) { return string_view.c_str(); } - - inline const wchar_t* to_wprintf_arg(const CWStringView string_view) { return string_view.c_str(); } - - static_assert(sizeof(CStringView) == sizeof(void*), "CStringView must be a simple wrapper around char*"); - static_assert(sizeof(CWStringView) == sizeof(void*), "CWStringView must be a simple wrapper around wchar_t*"); -} |
