Search code examples
c++c++20compiler-warnings

Should warnings about missing typename supressed in c++20?


Warning messages like:

missing 'typename' prior to dependent type name ... [-Wtypename-missing]

and

template argument for template type parameter must be a type; omitted 'typename' is a Microsoft extension [-Wmicrosoft-template]

If I understand right c++20 relaxed the need for typename. Does this mean that these warnings are outdated? Or should I add the (annoying) typename whenever there is warning? (I'm using Visual Studio / Clang12 / std=C++20.)


Solution

  • No, the warning is useful. Fix your code.

    C++20 relaxed the typename rules a little bit. But it's unrelated to this warning.

    MSVC considers typename to be (almost?) completely optional, and is non-conforming in this regard. Clang apparently can do that too, for compatibility with MSVC. The warning says that your code is non-conforming, and might not work on other compilers (most notably on GCC).