WAR for Issue #3577

This commit is contained in:
Nigel Stewart 2023-08-08 22:20:50 +10:00
parent a0b8a92e3d
commit 3bebba8f30
2 changed files with 26 additions and 1 deletions

View File

@ -2737,11 +2737,19 @@ FMT_FORMAT_AS(short, int);
FMT_FORMAT_AS(unsigned short, unsigned);
FMT_FORMAT_AS(long, long long);
FMT_FORMAT_AS(unsigned long, unsigned long long);
FMT_FORMAT_AS(Char*, const Char*);
FMT_FORMAT_AS(std::basic_string<Char>, basic_string_view<Char>);
FMT_FORMAT_AS(std::nullptr_t, const void*);
FMT_FORMAT_AS(detail::std_string_view<Char>, basic_string_view<Char>);
template <typename Char>
struct formatter<Char*, Char> : formatter<const Char*, Char> {
template <typename FormatContext>
auto format(const Char* val, FormatContext& ctx) const
-> decltype(ctx.out()) {
return formatter<const Char*, Char>::format(static_cast<const Char*>(val), ctx);
}
};
template <typename Char = char> struct runtime_format_string {
basic_string_view<Char> str;
};

View File

@ -1828,6 +1828,23 @@ TEST(format_test, join) {
EXPECT_EQ("0 1 0", fmt::format("{}", join(v4, " ")));
}
TEST(format_test, join_c_str) {
// {
// const char* argv[] = { "zero", "one", "two" };
// EXPECT_EQ("(zero, one, two)", fmt::format("({})", fmt::join(argv, argv + 3, ", ")));
// }
// {
char* argv[] = { "zero", "one", "two" };
EXPECT_EQ("(zero, one, two)", fmt::format("({})", fmt::join(argv, argv + 3, ", ")));
// }
{
// const char* const argv[] = { "zero", "one", "two" };
// EXPECT_EQ("(zero, one, two)", fmt::format("({})", fmt::join(argv, argv + 3, ", ")));
}
}
#ifdef __cpp_lib_byte
TEST(format_test, join_bytes) {
auto v = std::vector<std::byte>{std::byte(1), std::byte(2), std::byte(3)};