Place cXstring_view in a separate header
ADD
include/cstring_view.h
+#pragma once
+#include <string>
+
+namespace vcpkg
+{
+ struct cstring_view
+ {
+ cstring_view(const char* cstr) : cstr(cstr) {}
+ cstring_view(const std::string& str) : cstr(str.c_str()) {}
+
+ operator const char*() const { return cstr; }
+
+ const char* c_str() const { return cstr; }
+
+ private:
+ const char* cstr;
+ };
+
+ inline const char* to_printf_arg(const cstring_view spec) { return spec.c_str(); }
+
+ struct cwstring_view
+ {
+ cwstring_view(const wchar_t* cstr) : cstr(cstr) {}
+ cwstring_view(const std::wstring& str) : cstr(str.c_str()) {}
+
+ operator const wchar_t*() const { return cstr; }
+
+ const wchar_t* c_str() const { return cstr; }
+
+ private:
+ const wchar_t* cstr;
+ };
+
+ inline const wchar_t* to_wprintf_arg(const cwstring_view spec) { return spec.c_str(); }
+
+ static_assert(sizeof(cstring_view) == sizeof(void*), "cstring_view must be a simple wrapper around char*");
+ static_assert(sizeof(cwstring_view) == sizeof(void*), "cwstring_view must be a simple wrapper around wchar_t*");
+}

MODIFY
include/vcpkg_Strings.h
include/vcpkg_Strings.h
#pragma once
#include <vector>
-
-namespace vcpkg
-{
- struct cstring_view
- {
- cstring_view(const char* cstr) : cstr(cstr) {}
- cstring_view(const std::string& str) : cstr(str.c_str()) {}
-
- operator const char*() const { return cstr; }
-
- const char* c_str() const { return cstr; }
-
- private:
- const char* cstr;
- };
-
- inline const char* to_printf_arg(const cstring_view spec) { return spec.c_str(); }
-
-
- struct cwstring_view
- {
- cwstring_view(const wchar_t* cstr) : cstr(cstr) {}
- cwstring_view(const std::wstring& str) : cstr(str.c_str()) {}
-
- operator const wchar_t*() const { return cstr; }
-
- const wchar_t* c_str() const { return cstr; }
-
- private:
- const wchar_t* cstr;
- };
-
- inline const wchar_t* to_wprintf_arg(const cwstring_view spec) { return spec.c_str(); }
-}
+#include "cstring_view.h"
namespace vcpkg::Strings::details
{

MODIFY
vcpkglib/vcpkglib.vcxproj
vcpkglib/vcpkglib.vcxproj
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\include\BinaryParagraph.h" />
+ <ClInclude Include="..\include\cstring_view.h" />
<ClInclude Include="..\include\lazy.h" />
<ClInclude Include="..\include\LineInfo.h" />
<ClInclude Include="..\include\paragraph_parse_result.h" />

MODIFY
vcpkglib/vcpkglib.vcxproj.filters
vcpkglib/vcpkglib.vcxproj.filters
<ClInclude Include="..\include\vcpkg_expected.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\include\cstring_view.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file

Place cXstring_view in a separate header