Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-01-23 13:41:22


AMDG

Russell L. Carter wrote:
> then I
> get "void value not ignored as it ought to be" at the line:
> "FooFunc ff = put.getFooFunc();"
>
> I get the same thing if I try: FooFunc ff = MHBase<Put>::fooFO(put);
>
> Here's the code:
>
> #include <boost/function.hpp>
> #include <iostream>
>
> class MHBAccessor {
> template<class> friend class MHBase;
> template<class Derived>
> static int foo(Derived& derived, int i) { return derived.foo_(i); }
> };
> typedef boost::function<int (int)> FooFunc;
>
> template <class Derived>
> struct MHBase {
> Derived& derived() { return static_cast<Derived&>(*this); }
>
> int foo(int i) { return MHBAccessor::foo(this->derived(), i); }
>
> struct fooFO {
> fooFO(MHBase<Derived>& mhb) : mhb_(mhb) {}
> void operator()(int i) { mhb_.foo(i); }
>

This returns void. FooFunc expects int.
try

int operator()(int i) { return(mhb_.foo(i)); }

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net