Use cstring_view in all functions in Checks::
MODIFY
include/vcpkg_Checks.h
include/vcpkg_Checks.h
@@ -20,45 +20,45 @@ namespace vcpkg::Checks
}
// Part of the reason these exist is to not include extra headers in this one to avoid circular #includes.
- _declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessage);
+ _declspec(noreturn) void exit_with_message(const LineInfo& line_info, const cstring_view errorMessage);
- template <class...Args>
- _declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Args&... errorMessageArgs)
+ template <class Arg1, class...Args>
+ _declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
{
- exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
+ exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...).c_str());
}
- _declspec(noreturn) void throw_with_message(const LineInfo& line_info, const char* errorMessage);
+ _declspec(noreturn) void throw_with_message(const LineInfo& line_info, const cstring_view errorMessage);
- template <class...Args>
- _declspec(noreturn) void throw_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Args&... errorMessageArgs)
+ template <class Arg1, class...Args>
+ _declspec(noreturn) void throw_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
{
- throw_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
+ throw_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...).c_str());
}
- void check_throw(const LineInfo& line_info, bool expression, const char* errorMessage);
+ void check_throw(const LineInfo& line_info, bool expression, const cstring_view errorMessage);
- template <class...Args>
- void check_throw(const LineInfo& line_info, bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs)
+ template <class Arg1, class...Args>
+ void check_throw(const LineInfo& line_info, bool expression, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
{
if (!expression)
{
// Only create the string if the expression is false
- throw_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
+ throw_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...).c_str());
}
}
void check_exit(const LineInfo& line_info, bool expression);
- void check_exit(const LineInfo& line_info, bool expression, const char* errorMessage);
+ void check_exit(const LineInfo& line_info, bool expression, const cstring_view errorMessage);
- template <class...Args>
- void check_exit(const LineInfo& line_info, bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs)
+ template <class Arg1, class...Args>
+ void check_exit(const LineInfo& line_info, bool expression, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
{
if (!expression)
{
// Only create the string if the expression is false
- exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArgs...).c_str());
+ exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...).c_str());
}
}
}

MODIFY
src/vcpkg_Checks.cpp
src/vcpkg_Checks.cpp
@@ -30,19 +30,19 @@ namespace vcpkg::Checks
::exit(exit_code);
}
- __declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessage)
+ __declspec(noreturn) void exit_with_message(const LineInfo& line_info, const cstring_view errorMessage)
{
System::println(System::color::error, errorMessage);
exit_fail(line_info);
}
- __declspec(noreturn) void throw_with_message(const LineInfo& line_info, const char* errorMessage)
+ __declspec(noreturn) void throw_with_message(const LineInfo& line_info, const cstring_view errorMessage)
{
print_line_info_if_debug(line_info);
throw std::runtime_error(errorMessage);
}
- void check_throw(const LineInfo& line_info, bool expression, const char* errorMessage)
+ void check_throw(const LineInfo& line_info, bool expression, const cstring_view errorMessage)
{
if (!expression)
{
@@ -58,7 +58,7 @@ namespace vcpkg::Checks
}
}
- void check_exit(const LineInfo& line_info, bool expression, const char* errorMessage)
+ void check_exit(const LineInfo& line_info, bool expression, const cstring_view errorMessage)
{
if (!expression)
{

Use cstring_view in all functions in Checks::