ARTICLE AD BOX
MSVC is wrong and the others are correct.
const has no effect in this case, but it is nevertheless part of the function template's signature.
MSVC somehow forgets that the meaningless const is part of the signature when it comes to this assignment:
const auto f(auto) { return 1; } int(*x)(int) = f;So, MSVC accepts it, while the other implementations rightfully reject it.
MSVC is also inconsistent. It only seems to reject the assignment if it's a function template with a deduced return type:
const auto f(int) { return 1; } // ok (only deduced return type) const int f(auto) { return 1; } // ok (only function template) const auto f(auto) { return 1; } // NOK (both) // const int(*x)(int) = f;It does, however, accept old-school template arguments:
template<class T> const auto f(T) { return 1; } const int(*x)(int) = f; // ok by all implementations126k7 gold badges96 silver badges161 bronze badges
2 Comments
Sidenote: The C++ standard has clear definition for the term "signature" and it does NOT include the function's return type for non-template functions. link
2026-03-31T06:54:47.177Z+00:00
Explore related questions
See similar questions with these tags.


