Can't define template member function using VC++ 6.0.

J

Jason Heyes

How can I define the member function of this template class using VC++ 6.0?
The only way I got it to work was to define the member function inline.

template <typename T>
class Seq
{
public:
template <typename Pred>
Seq<T> find(Pred pred) const;
};

Any help is appreciated.
 
E

ES Kim

Jason Heyes said:
How can I define the member function of this template class using VC++ 6.0?
The only way I got it to work was to define the member function inline.

template <typename T>
class Seq
{
public:
template <typename Pred>
Seq<T> find(Pred pred) const;
};

Defining a template member function is something like this:

template<typename T>
template <typename Pred>
Seq<T> Seq<T>::find(Pred pred) const { /* ... */ }

But if VC++ complains about this, you have no choice other than making
it inline. Don't worry about code bloat -- if the function is complex enough,
it will not be inlined anyway. ;-)
 
J

Jason Heyes

ES Kim said:
Defining a template member function is something like this:

template<typename T>
template <typename Pred>
Seq<T> Seq<T>::find(Pred pred) const { /* ... */ }

But if VC++ complains about this, you have no choice other than making
it inline. Don't worry about code bloat -- if the function is complex
enough,
it will not be inlined anyway. ;-)

Ok thanks for the help.
 
J

Jonathan Turkanis

VC++ didn't support out-of-class definitions of member templates until 7.1.

If this is a concern, you can use the microsoft pragma auto_inline to disable
inline expansion.

Jonathan
 

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

No members online now.

Forum statistics

Threads
474,197
Messages
2,571,038
Members
47,633
Latest member
BriannaLyk

Latest Threads

Top