Boost logo

Boost Users :

From: darrenvhart (dvhart_at_[hidden])
Date: 2003-05-30 11:56:18


OK, this group finally let me replay to the list.

I added the header file for apply and changed the line you mentioned
to use apply<bool>(), but now it won't compile, comlaining about
noncopyable objects. Any thoughts?

---snip---
old_test.cpp:87: instantiated from here
/usr/include/boost/noncopyable.hpp:27: error: `
   boost::noncopyable::noncopyable(const boost::noncopyable&)' is private
/usr/include/boost/bind.hpp:186: error: within this context
/usr/include/boost/bind.hpp: In member function `R
   boost::_bi::list1<A1>::operator()(boost::_bi::type<R>, F, A&) const
[with R
   = bool, F = boost::apply<bool>, A = boost::_bi::list0, A1 =
   boost::_bi::bind_t<const boost::signal<bool ()(),
boost::last_value<bool>,
   int, std::less<int>, boost::function<bool ()(),
std::allocator<void> > >&,
   boost::_mfi::dm<boost::signal<bool ()(), boost::last_value<bool>, int,
   std::less<int>, boost::function<bool ()(), std::allocator<void> > >,
   widget>, boost::_bi::list1<boost::_bi::value<widget*> > >]':
/usr/include/boost/bind.hpp:186: error: initializing argument 1 of `R
   boost::apply<R>::operator()(F) const [with F = boost::signal<bool ()(),
   boost::last_value<bool>, int, std::less<int>, boost::function<bool
()(),
   std::allocator<void> > >, R = bool]'

--- In Boost-Users_at_[hidden], "Peter Dimov" <pdimov_at_m...> wrote:
> Darren Vincent Hart wrote:
> [...]
> > struct widget
> > {
> > boost::signal<bool ()> sig;
> > boost::signal<bool (char)> keypress;
> > bool test()
> > {
> > cout << "widget::test() - sig empty: " << (sig.empty() ? "true" :
> > "false") << endl;
> > sig();
> > return true;
> > }
> > };
> [...]
> > // bind to a widget signal handler, BROKEN
> > //handler<bool> handler_b( boost::bind<bool>(&widget::sig, &widget_a)
> > ); // <-- Broken
> [...]
> > // store the function object returned by binding a widget signal,
> > BROKEN
> > //boost::function<bool ()> fp = boost::bind(&widget::sig, &widget_a);
> > // <-- BROKEN
> >
> > // executre the functor returned by binding a widget signal, BROKEN
> > // (builds, but doesn't really call widget_a.sig())
> > boost::bind(&widget::sig, &widget_a)(); // <-- Test if binding works
> > at all, it doesn't
>
> bind(&widget::sig, &widget_a)() gets you a reference to
widget_a->sig since
> &widget::sig is a data member. You still need to call it.
>
> bool call(signal<bool()> const & s) { return s(); }
>
> bind(call, bind(&widget::sig, &widget_a)) ();
>
> will probably do what you want.
>
> You can use apply<> from <boost/bind/apply.hpp> instead of 'call':
>
> bind(apply<bool>(), bind(&widget::sig, &widget_a)) (); // should call
> widget_a->sig
>
> HTH


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