1 // Boost.Signals library
3 // Copyright Douglas Gregor 2001-2003. Use, modification and
4 // distribution is subject to the Boost Software License, Version
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 // For more information, see http://www.boost.org
10 #include <boost/signals/signal2.hpp>
14 struct first_positive
{
15 typedef T result_type
;
17 template<typename InputIterator
>
18 T
operator()(InputIterator first
, InputIterator last
) const
20 while (first
!= last
&& !(*first
> 0)) { ++first
; }
21 return (first
== last
) ? 0
28 typedef T result_type
;
30 T
operator()(const T
& x
, const T
& y
) const
32 std::cout
<< "Dividing " << x
<< " and " << y
<< std::endl
;
39 boost::signal2
<int, int, int, first_positive
<int> > sig_positive
;
40 sig_positive
.connect(std::plus
<int>());
41 sig_positive
.connect(std::multiplies
<int>());
42 sig_positive
.connect(std::minus
<int>());
43 sig_positive
.connect(noisy_divide
<int>());
45 assert(sig_positive(3, -5) == 8); // returns 8, but prints nothing