471,585 Members | 1,169 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,585 software developers and data experts.

Template parse error

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
4 1541
"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
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
"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
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.

Similar topics

2 posts views Thread by Dave O'Hearn | last post: by
1 post views Thread by David M Noriega | last post: by
2 posts views Thread by Nicolas GALAN | last post: by
7 posts views Thread by Lionel B | last post: by
1 post views Thread by gio | last post: by
5 posts views Thread by lobequadrat | last post: by
9 posts views Thread by Adam Nielsen | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.