79832374

Date: 2025-11-28 08:22:50
Score: 2.5
Natty:
Report link

I did manage to find a solution based on the formattable function from the question and the concept from this StackOverflow answer:

template<typename T>
consteval bool formattable()
{
    auto fmt_parse_ctx = std::format_parse_context(".2");
    return std::formatter<T>().parse(fmt_parse_ctx) == fmt_parse_ctx.end();
}

template<typename T> concept Formattable = requires
{
    typename std::type_identity_t<int[(formattable<T>(),1)]>;
};

static_assert(Formattable<double>);
static_assert(!Formattable<int>);

Demo on Compiler Explorer.

Reasons:
  • Blacklisted phrase (1): StackOverflow
  • Probably link only (1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Jens