Full specialization of a member function template of a class template

From: Dave (better_cs_now_at_yahoo.com)
Date: 05/05/04


Date: Tue, 4 May 2004 17:21:29 -0700


Hello all,

I am trying to create a full specialization of a member function template of
a class template. I get the following errors:

Line 29: 'foo<T1>::bar' : illegal use of explicit template arguments
Line 29: 'bar' : unable to match function definition to an existing
declaration

What am I doing wrong?

Thanks,
Dave

#include <iostream>

using namespace std;

template <typename T1>
class foo
{
   public:
      template <typename T2>
      void bar(const T2 &param);
};

template <typename T1>
template <typename T2>
void foo<T1>::bar(const T2 &param)
{
   static_cast<void>(param);

   cout << "Point 1" << endl;
}

template <typename T1>
template <>
void foo<T1>::bar<double>(const double &param)
{
   static_cast<void>(param);

   cout << "Point 2" << endl;
}

int main()
{
   foo<int> var;

   var.bar(4.5);
}



Relevant Pages