Boost logo

Boost Users :

Subject: Re: [Boost-users] [Bind] binding a functor simple example - compiler error
From: Rutger ter Borg (rutger_at_[hidden])
Date: 2010-05-27 10:02:43


Viter :O) wrote:

> I'm having problems to compile a simple example and I don't
> Know what could it be the problem.
>
> my main.cpp code is the following:
>
> -- main.cpp -----------------------------------------------
> #include <boost/bind.hpp>
> #include <iostream>
>
> int main() {
> struct F {
> int operator() (int a, int b) const { return a + b; }
> };
> F f;
>
> std::cout << " f: " << boost::bind(f,1,2)() << std::endl;
>
> return 0;
> }
> -----------------------------------------------------------

Please try moving F out of main, and say something about its result type,

struct F {
  typedef int result_type;
  int operator() (int a, int b) const { return a + b; }
};

int main() {
    F f;
    std::cout << " f: " << boost::bind(f,1,2)() << std::endl;
    return 0;
}

HtH,

Rutger


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