This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


Max Lawson writes:

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

egcs is correct.

> template<class O, class T>
> class mu_mem_fun_mvars

This declares a class, but then you use it as a function:

>   cout << bar(mu_mem_fun_mvars(ff,&foo::f)) << endl;

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

There's no such thing as a call to a constructor, since there's no
class named mu_mem_fun_mvars.  You could achieve the desired effect by
defining a template function:

template<class O, class T>
mu_mem_fun_mvars<O,T> mu_mem_fun_mvars_f(O& obj, T (O::*m_func)(const T&)) {
  return mu_mem_fun_mvars<O,T>(obj, m_func);
}

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]