lundi 7 octobre 2019

aggregate has incomplete type and cannot be defined when dealing with default template parameters

I want to try to forward declare a templated class with a default template parameter.

My code looks like this:

 #include <bits/stdc++.h>
 using namespace std;

 template <typename T = int> class temp;

 main()
 {
      temp<> def; // error here
 }

 template <typename T>
 class temp
 {
      T val;
 public:
      temp() = default;
 // other stuff can go here, not relevant though
 }

I am working in c++11. Is there any way around this error or am I just stuck?

Aucun commentaire:

Enregistrer un commentaire