Boost logo

Boost :

From: Douglas Paul Gregor (gregod_at_[hidden])
Date: 2003-12-25 01:46:21


On Wed, 24 Dec 2003, Jim Apple wrote:
> #include <boost/function.hpp>
> using namespace boost;
>
>
> char f(int, int = 0) { return 'a'; };
> function<void (int)> b = f;
>
>
> int main() {
> b(1);
> }

This should not compile. Some compilers based on the EDG front end
(perhaps others) will compile it, but it doesn't really work. Try this:

int f(int x = 0) { return x; }
int g(int x = 2) { return x; }

int main()
{
  boost::function<int()> fun;
  fun = f;
  cout << fun() << ' ';
  fun = g;
  cout << fun() << endl;
}

        Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk