diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2018-01-17 19:35:31 -0800 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2018-01-17 19:38:17 -0800 |
| commit | 458dafc812a1bc4f3290397601457e93f53b2dea (patch) | |
| tree | e71a22d5be9f8e0f75841c00f21c88660ebc82bc /toolsrc/include | |
| parent | c7296cf1f21104b15d9cfe931416245768b484e3 (diff) | |
| download | vcpkg-458dafc812a1bc4f3290397601457e93f53b2dea.tar.gz vcpkg-458dafc812a1bc4f3290397601457e93f53b2dea.zip | |
Add new struct: StringLiteral
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/vcpkg/base/stringliteral.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/toolsrc/include/vcpkg/base/stringliteral.h b/toolsrc/include/vcpkg/base/stringliteral.h new file mode 100644 index 000000000..c07f04cec --- /dev/null +++ b/toolsrc/include/vcpkg/base/stringliteral.h @@ -0,0 +1,26 @@ +#pragma once + +#include <vcpkg/base/cstringview.h> + +namespace vcpkg +{ + struct StringLiteral + { + template<int N> + constexpr StringLiteral(const char (&str)[N]) : m_size(N), m_cstr(str) + { + } + + constexpr const char* c_str() const { return m_cstr; } + constexpr size_t size() const { return m_size; } + + operator CStringView() const { return m_cstr; } + operator std::string() const { return m_cstr; } + + private: + size_t m_size; + const char* m_cstr; + }; + + inline const char* to_printf_arg(const StringLiteral str) { return str.c_str(); } +} |
