I decided to change a class in my code to become a template. This came up with the 'X' is not a template type error no matter what I changed. In the end I rolled back the changes and made the simplest change possible: I put template <typename T> in front of the class so I had:
template <typename T>
class X
{
...
Still get the error.
So I made a MCVE but that works fine.
Why does that one additional line cause an error?
#include <vector>
#include <iostream>
class A
{
};
template <class D>
class S : public D
{
};
template <class T> // line 13
class OM
{
public:
explicit OM(int a, int b , int c)
{
std::cout << "OM ctor\n";
std::cout << "a = " << a << " , b = " << b << " , c = " << c << " \n";
}
std::vector<A> v;
};
int main(int, const char*[])
{
OM om(1,2,3);
//OM<S<A>> om(1,2,3); // line 28
}
In the MCVE above, if line 13 is commented out the code compiles, but left in gives a missing template arguments before 'om' error, not 'X' is not a template type like I get in the full program. Line 28 is where I want to get to and I can easily modify the MCVE to achieve that.
Aucun commentaire:
Enregistrer un commentaire