error: template-id does not match any template declaration

J

Joseph Turian

I have a class Feature defined, which is a kind of Vocab:

template <class T, unsigned I>
class Vocab : boost::totally_ordered<Vocab<T,I> > {
public:
Vocab();
Vocab(const T& t);
template<typename V> Vocab(V v, bool dummy);
....
};
typedef Vocab<string, 0> Feature;

Then, I try to specialize (define?) the templated constructor:
template<>
inline Feature::Vocab(pair<parser::id_ty, string> p, bool dummy) {
...
}

This code compiles under g++ 3.4, but under g++ 4 I get the following
errors:

src/specialize-bdt.H:37: error: template-id 'Vocab<>' for
'bdt::Vocab<std::string, 0u>::Vocab(std::pair<parser::id_ty,
std::string>, bool)' does not match any template declaration
src/specialize-bdt.H:37: error: invalid function declaration

What is the problem here?

Thanks,
Joseph
 
V

Victor Bazarov

Joseph said:
I have a class Feature defined, which is a kind of Vocab:

template <class T, unsigned I>
class Vocab : boost::totally_ordered<Vocab<T,I> > {
public:
Vocab();
Vocab(const T& t);
template<typename V> Vocab(V v, bool dummy);
....
};
typedef Vocab<string, 0> Feature;

Then, I try to specialize (define?) the templated constructor:
template<>
inline Feature::Vocab(pair<parser::id_ty, string> p, bool dummy) {
...
}

This code compiles under g++ 3.4, but under g++ 4 I get the following
errors:

src/specialize-bdt.H:37: error: template-id 'Vocab<>' for
'bdt::Vocab<std::string, 0u>::Vocab(std::pair<parser::id_ty,
std::string>, bool)' does not match any template declaration
src/specialize-bdt.H:37: error: invalid function declaration

What is the problem here?

I don't think you can use 'Feature' to write the specialisation (but
I can be wrong). Have you tried

template<>
template<>
inline Vocab<string,0>::Vocab(pair<par....

?

V
 
J

Joseph Turian

I don't think you can use 'Feature' to write the specialisation (but
I can be wrong). Have you tried

template<>
template<>
inline Vocab<string,0>::Vocab(pair<par....

Thanks for the advice. At least according to gcc, I can use Feature:
template<>
template<>
inline Feature::Vocab(pair<par....

The second "template<>" did the trick, so thanks! :)

Best,
Joseph
 

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
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top