template function within class template not not resolving?

J

jrwats

I'm trying to write a templated function within a templated class, but
keep getting:
Test.h:31: error: no matching function for call to
‘List<int>::Map(List<T>::blah() [with T = int]::Functor)’
Test.h:45: error: no matching function for call to ‘List<int>::Map()’

With the following code:
template <class T>
class List
{
public:
// Function template
template <class Functor>
int Map(const Functor& func);

// Returns NULL if not found.
int blah();
int blah2();
};

template <class T>
template <class Functor>
int List<T>::Map(const Functor& func)
{
return func() ? 0 : 1;
}

template<class T>
int List<T>::blah()
{
class Functor
{
bool operator()()
{
return true;
}
};
return Map(Functor());
}


template<class T>
int List<T>::blah2()
{
class Functor
{
bool operator()()
{
return true;
}
};
return Map<Functor>();
}

void blah()
{
List<int> list;
list.blah();
list.blah2();
}
 

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,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top