Skip to content

Acceptable format strings #3052

Description

@matt77hias

Any design reason why some of the below conversions do not work?

#include <fmt/core.h>
#include <fmt/xchar.h>

using FormatString     = fmt::basic_format_string< char,    int >;
using FormatWideString = fmt::basic_format_string< wchar_t, int >;

auto main() -> int
{
    [[maybe_unused]] auto f1 = fmt::format(FormatString    {  "{}" }, 1);
    [[maybe_unused]] auto f2 = fmt::format(FormatWideString{ L"{}" }, 1);// ERROR

    [[maybe_unused]] auto f3 = fmt::format( "{}", 1);
    [[maybe_unused]] auto f4 = fmt::format(L"{}", 1);

    [[maybe_unused]] auto f5 = fmt::format(fmt::basic_string_view< char >{    FormatString    {  "{}" } }, 1);// ERROR
    [[maybe_unused]] auto f6 = fmt::format(fmt::basic_string_view< wchar_t >{ FormatWideString{ L"{}" } }, 1);

    return 0;
}

https://godbolt.org/z/PYbcbWbaf

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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