Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Class template problem: template argument 1 is invalid

Reply
Thread Tools

Class template problem: template argument 1 is invalid

 
 
jtravs@gmail.com
Guest
Posts: n/a
 
      09-07-2012
Hi all, I have a problem with a class template. I want the private data in a class to be a vector of vectors of some kind of numeric type, i.e:

std::vector<std::vector<double> >
std::vector<std::vector<std::complex<double> > >

But I want the type of vector (I'm using a library of third party vectors along with stl vectors), and the element type to be templated. I tried template templates but now I don think that is the solution to my problem. A highly simplified example is:

#include <complex>
#include <vector>
template<typename T>
class Fred {
std::vector<T> data_;
};
int main(){
Fred<std::vector<double> > works;
//Fred<std::vector<std::complex<double> > doesnt_work;
return 0;
}

As shown it compiles fine, but if I uncomment the second line in main, I get the error (g++ 4.6):

error: template argument 1 is invalid

Why do I get this error? And does anyone have a suggested fix?

Thanks,
John
 
Reply With Quote
 
 
 
 
jtravs@gmail.com
Guest
Posts: n/a
 
      09-07-2012
>
> Why do I get this error? And does anyone have a suggested fix?
>


OK, this was solved on stack overflow: I missed a > in the second line! Yes, I'm stupid! Though the error message is a little useless.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
r H2 deduce deduce template argument of a template class inheritingfrom a non template base? nguillot C++ 5 03-08-2009 05:56 PM
Template argument as template argument nw C++ 0 04-14-2008 01:36 PM
How do fix: "Wrong number of arguments" / "invalid propert assignment"/ "Invalid argument" Java Guy Javascript 1 10-15-2006 08:41 PM
How do fix: "Wrong number of arguments" / "invalid propert assignment"/ "Invalid argument" Java Guy Java 1 10-15-2006 08:31 PM
Local class instances invalid template argument Matthias C++ 10 01-28-2005 10:22 AM



Advertisments