Skip to content

std::optional<const T> doesn't work #4561

Description

@OleksandrKvl

fmt::print("{}", std::optional<const int>{}); doesn't compile. Below is my initial analysis (I'm not really familiar with fmt internals):

  • is_formattable<std::optional<const int>> is false because
  • has_formatter is false because
  • decltype(formatter<U, Char>().format(*p, *ctx), std::true_type()) is SFINAEd out because
  • formatter<U, Char>() is invalid because
  • default ctor for formatter<std::optional<const int>> is deleted because
  • default ctor for formatter<T, Char> underlying_ here is deleted because
  • default ctor for formatter<const int> is deleted here probably because
  • native_formatter is not selected because type_constant<const int>::value is custom_type instead of int_type

I can only guess that remove_cv_t is required somewhere in that chain.

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