On Thu, 12 Oct 2000, Jean-Marc Lasgouttes wrote:
> So, even when trying to ignore the vsnprntf problem, it seems I cannot
> use the brand new compare_memfun thingie. Since the error message (or
> rather the template definition) is chinese to me, I'd appreciate a fix.
>
> mycxx -DHAVE_CONFIG_H -I. -I../../lyx-devel/src -I. -I.. -I../../lyx-devel
> -I../../lyx-devel/boost -I../../lyx-devel/src/cheaders
> -I/afs/rocq/home/meval/common/include -I/usr/local/include -g0 -c
> ../../lyx-devel/src/MenuBackend.C cxx: Error:
> ../../lyx-devel/src/MenuBackend.C, line 404: no instance of function
> template "compare_memfun" matches the argument list argument types are:
> (const std::string &(Menu::*)() const, const std::string)
> compare_memfun(&Menu::name, name)) != end();
> -----------------------^
>
>
> JMarc
Looks like it's a const-thing. The foul hack below allows MenuBackend.C to
compile.
Angus
class compare_memfun_t {
public:
compare_memfun_t(R(C::*p)(), A const & a)
: pmf(p), arg(a) {}
compare_memfun_t(R(C::*p)() const, A const & a)
: pmfc(p), arg(a) {}
bool operator()(C * c) {
return (c->*pmf)() == arg;
}
bool operator()(C & c) {
return (c.*pmf)() == arg;
}
bool operator()(C const * c) const {
return (c->*pmfc)() == arg;
}
bool operator()(C const & c) const {
return (c.*pmfc)() == arg;
}
private:
R(C::*pmf)();
R(C::*pmfc)() const;
A const & arg;
};
template <class R, class C, class A>
compare_memfun_t<R, C, A>
compare_memfun(R(C::*p)() const, A const & a)
{
return compare_memfun_t<R, C, A>(p, a);
}
template <class R, class C, class A>
compare_memfun_t<R, C, A>
compare_memfun(R(C::*p)(), A const & a)
{
return compare_memfun_t<R, C, A>(p, a);
}