By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,159 Members | 913 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,159 IT Pros & Developers. It's quick & easy.

Template parse error

P: n/a
In a header, I have the following class template:

template<typename _ListItem>
class SimpleListItemConvert : public pqxxobject::RowConvert<_ListItem>
{
};

However, this won't compile:

$ g++ -c simplelist.cc -o simplelist.o
In file included from simplelist.h:11,
from simplelist.cc:1:
simplelist.h:127: error: `SimpleListItemConvert' is not a
template type
Why is it not a template type? Can a template class not inherit from
another template? At this point, I haven't even tried to instantiate
it.
Thanks,
Roger

--
Roger Leigh

Printing on GNU/Linux? http://gimp-print.sourceforge.net/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
Jul 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Roger Leigh" <${******@invalid.whinlatter.uklinux.net.invalid > wrote...
In a header, I have the following class template:

template<typename _ListItem>
class SimpleListItemConvert : public pqxxobject::RowConvert<_ListItem>
{
};

However, this won't compile:

$ g++ -c simplelist.cc -o simplelist.o
In file included from simplelist.h:11,
from simplelist.cc:1:
simplelist.h:127: error: `SimpleListItemConvert' is not a
template type
Why is it not a template type? Can a template class not inherit from
another template? At this point, I haven't even tried to instantiate
it.


(a) You're not inheriting from a template, you're inheriting from
an instantiation of a template. pqxxobject::RowConvert<_ListItem>
is a concrete class.

(b) Please read FAQ 5.8 and follow its recommendations. There is
not enough information in your post to advise anything beyond that
you probably have 'SimpleListItemConvert' forward-declared somewhere
as a class and not a template.

Victor
Jul 22 '05 #2

P: n/a
Roger Leigh wrote in news:87************@wrynose.whinlatter.uklinux.net :
In a header, I have the following class template:

template<typename _ListItem>
class SimpleListItemConvert : public
pqxxobject::RowConvert<_ListItem> {
};

It (Most probably) isn't your problem but identifiers like _Listitem,
i.e. that start with a _ followed by one of A-Z, are reserverd for
you implementation.
However, this won't compile:

$ g++ -c simplelist.cc -o simplelist.o
In file included from simplelist.h:11,
from simplelist.cc:1:
simplelist.h:127: error: `SimpleListItemConvert' is not a
template type

You need to tell us what pqxxobject and pqxxobject::RowConvert are.
preferably showing us declaration's.

Why is it not a template type? Can a template class not inherit from
another template? At this point, I haven't even tried to instantiate
it.


Yes thay can, example:

struct X
{
template < typename T > struct XX
{
};
};
template < typename T > struct Y : X::XX< T >
{
};

int main()
{
Y< int > yi;
}

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #3

P: n/a
"Victor Bazarov" <v.********@comAcast.net> writes:
"Roger Leigh" <${******@invalid.whinlatter.uklinux.net.invalid > wrote...
In a header, I have the following class template:

template<typename _ListItem>
class SimpleListItemConvert : public pqxxobject::RowConvert<_ListItem>
{
};

However, this won't compile:

$ g++ -c simplelist.cc -o simplelist.o
In file included from simplelist.h:11,
from simplelist.cc:1:
simplelist.h:127: error: `SimpleListItemConvert' is not a
template type
Why is it not a template type? Can a template class not inherit from
another template? At this point, I haven't even tried to instantiate
it.
(a) You're not inheriting from a template, you're inheriting from
an instantiation of a template. pqxxobject::RowConvert<_ListItem>
is a concrete class.


ACK.
(b) Please read FAQ 5.8 and follow its recommendations. There is
not enough information in your post to advise anything beyond that
you probably have 'SimpleListItemConvert' forward-declared somewhere
as a class and not a template.


That was 100% spot on. There was a friend class declaration in
another class--I didn't realise friend counted as forward declaration.

I'll include more detail next time.
Many thanks,
Roger

--
Roger Leigh

Printing on GNU/Linux? http://gimp-print.sourceforge.net/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
Jul 22 '05 #4

P: n/a
Roger Leigh wrote:
In a header, I have the following class template:

template<typename _ListItem>
class SimpleListItemConvert : public pqxxobject::RowConvert<_ListItem>
{
};

However, this won't compile:


works for me:

class pqxxobject
{
public:

template <typename z>
struct RowConvert
{
};

};

template<typename _ListItem>
class SimpleListItemConvert : public pqxxobject::RowConvert<_ListItem>
{
};

Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.