aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/vcpkg/base/stringliteral.h26
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(); }
+}