Boost logo

Boost Users :

From: Susan Flynn (imadveng_at_[hidden])
Date: 2005-05-12 20:21:27


>
> In this context the library expects you to pass a function that takes
> 'string' and returns nothing. However, you pass a member function, which
> has implicit 'this' argument. I'd suggest this:
>
> #include <boost/bind.hpp>
>
> .....
>
> ->notify(boost::bind(&Report::PrintName, this, _1))
>
> HTH,
> Volodya
>

Hi,
Thanks for the quick reply. I tried your suggestion and it
didn't get rid of the compile error. I had also previously
tried making PrintName be a function (instead of a member
function) and it didn't compile either.
To simplify everything, I took the first example from the
tutorial, first.cpp, and added a notify and a new, simple
function (boost 1.32, libs/program_options/example). In
first.cpp, change line 23:
("compression", po::value<int>(), "set compression level")
---to---
("compression", po::value<int>()->default(2)->notify(&PrintComp),
                "set compression level")
then add this function before main:
void PrintComp(int compr)
{
  cout << "***Compression level is now " << compr << "\n";
}

The compile error is (still) 'invalid use of void expression'.
Does my code above work for you?

thanks again for your help,
susan.


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