Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Using std:::byte + fmt::join + wide chars fails to compile since 11.1 #4479

@patstew

Description

@patstew

The following test code:

  std::byte v[3] = {std::byte(10), std::byte(20), std::byte(30)};
  EXPECT_EQ(fmt::format(L"({})", fmt::join(v, v + 3, L", ")), L"(10, 20, 30)");
  EXPECT_EQ(fmt::format(L"({:02X})", fmt::join(v, v + 3, L", ")), L"(0A, 14, 1E)");

fails to compile at the 3rd line since 11.1.

Adding:

namespace std {
template <typename T, FMT_ENABLE_IF(std::is_same<T, std::byte>::value)>
inline auto format_as(T b) -> unsigned char {
    return static_cast<unsigned char>(b);
}
} // namespace std

back instead of the member format_as thing seems to fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions