yet another template instantiation problem (w/ short snapshot :)

Max Lawson mlawson@drfmc.ceng.cea.fr
Thu Oct 30 08:54:00 GMT 1997


	Hi ! 

The following program doesn't compile with egcs-971023 on a 
i586-pc-linux-glibc1 box (libc5.4.39; boot_cflags="-g -O2")


Here's the source file: 

----------------z.cc-----------------------------------------------
#include <iostream.h>


template<class O, class T>
class mu_mem_fun_mvars
{
private:

  O *obj_;
  T (O::*m_func_)(const T&);

public:

  // constructor
  explicit mu_mem_fun_mvars(O& obj, T (O::*m_func)(const T&))
    : obj_(&obj), m_func_(m_func)
  { }

  // evaluation of the integrand at the "current" point v
  T operator() ( const T& v ) { return (obj_->*m_func)(v); }
};



struct foo 
{
  double f(const double& t) { return 2*t; }
};

foo ff;

template<class F, class T> 
T bar( F& z) { return z(1.0); }

int main()
{
  cout << bar(mu_mem_fun_mvars(ff,&foo::f)) << endl;
  return 0;
}
--------------------------------------------------


and the compilation results:

g++ -Wall -g -O6  z.cc
z.cc: In function `int main()':
z.cc:38: warning: implicit declaration of function `int mu_mem_fun_mvars(...)'
z.cc:38: warning: cannot pass objects of type `double (foo::*)(const double &)' through `...'
z.cc:38: incomplete type unification
z.cc:38: no matching function for call to `bar (int)'


=> Could sbdy explain me why the call to the class "mu_mem_fun_mvars" 
constructor isn't handled the right way ? 

This behaviour, IMHO, in a larger source make cc1plus have a fatal signal 11 :(


Thanx in advance, Max





More information about the Gcc-bugs mailing list