Pointers to partially specialized template methods, type confusion

From: Martin Magnusson (loveslave_at_frustratedhousewives.zzn.com)
Date: 11/23/04


Date: 23 Nov 2004 01:04:37 -0800

I have a partially specialized templated class, which at one point needs
to pass pointers to some of its methods to another function. However, it
seems that my compiler (gcc) and me don't quite agree on the types for
the methods.

In the code below, the constructor to NLF2 (near the bottom) takes as
its last two arguments two function pointers of type void(*)(...), and
apparently &PR<2>::PR_init is of type void(PR<2>::*)(...).

If I remove the partial specialization, and just leave a general
implementation of PR, it works.

Does anyone know what I'm missing here? (The NLF class comes from the
OPT++ library for numerical optimization)

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
#include "OPT/NLF.h"
#include "OPT/NLP.h"

template< int TD >
class PR;

const int D = 2;
class PR<D>
{
public:
  void init();

private:
  void PR_function(int mode, int ndim,
                   const ColumnVector& x,
                   real& fx,
                   ColumnVector& gx,
                   SymmetricMatrix& Hx, int& result );
  void PR_init(int dim, ColumnVector& parameters);
};

//template<int D>
void PR<D>::PR_function(int mode, int ndim,
                   const ColumnVector& x,
                   real& fx,
                   ColumnVector& gx,
                   SymmetricMatrix& Hx, int& result) {}

//template<int D>
void PR<D>::PR_init(int dim, ColumnVector& parameters) {}

//template<int D>
void PR<D>::init()
{
  NLF2 optimizer
    (3, &PR<2>::PR_function, &PR<2>::PR_init );
  //======== ERROR ON THE LINE ABOOVE =========
}

int main()
{
  PR<2> pr;
  pr.init();
  return 0;
}

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////