Say I have the following bit of code:
Code:
#include <iostream>
using std::cout;
#include <vector>
using std::vector;
template <class T>
class foo {
public:
void bar() const;
};
template <class T>
void
foo<T>::bar () const
{
cout << "template generated\n";
}
void
foo<vector<int> >::bar() const
{
cout << "template specialized\n";
}
int
main(int argc, char *argv[])
{
foo<int> f;
foo<vector<int> > g;
f.bar();
g.bar();
return 0;
}
Its output is then
Code:
template generated
template specialized
How can I specialize
foo<vector<T> >::bar() const?
ie, specialize foo::bar() for objects from templated container types?