Template parse error

R

Roger Leigh

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
 
V

Victor Bazarov

Roger Leigh said:
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
 
R

Rob Williscroft

Roger Leigh wrote in
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.
 
R

Roger Leigh

Victor Bazarov said:
(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
 
G

Gianni Mariani

Roger said:
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>
{
};
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,405
Latest member
DavidCex

Latest Threads

Top