The following code compiled well in trunk gcc and clang, but failed in msvc for c++20 mode:
template <typename T = int>
void f(void* ptr, T&& t = {}) {
if (ptr) {
f(nullptr);
}
}
with the messages:
error C2672: 'f': no matching overloaded function found note: could be 'void f(void *,T &&)' note: 'void f(void *,T &&)': could not deduce template argument for 'T' note: 'f': function declaration must be available as none of the arguments depend on a template parameter
Works well for msvc for c++17 mode, since /permissive-
is only available by default since c++20.
Can be easily fixed for msvc c++20 by specifying template type explicitly, i.e. f<T>(nullptr);
in the function body.
Who is right according to the standard? I'm interested for both c++17 and c++20 modes. Is there any changes will come with upcoming c++23?
/permissive
flag on and off.