0

The following code produces two compiler errors in vs2015:

C2995: void TestSpecialization<T>::f(void): function template has already been defined

C3860: template argument list following class template name must list parameters in the order used in template parameter list.

template <typename T>

class TestSpecialization
{
public:
    void f() {}
};

template <typename T>
void TestSpecialization<T*>::f() // C3860, C2995
{}

WRONG ORDER?! This initially seemed nearly reasonable... the template originally had 3 parameters (in the correct order, btw). But now it has a single parameter, how in the name of all that links do you manage to get that in the wrong order?!

Thoughts

Methinks the type listed in the error for 2995 is a clue, it lists the original type without the T*.

Just to muddy the waters, std::is_pointer compiles just fine.

It's entirely possible that we're using some strange compatibility flag on the compiler.

No, I can't use if constexpr instead. Ah... to dream.

Mark Storer
  • 15,672
  • 3
  • 42
  • 80

0 Answers0