]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/signals/example/maximum.cpp
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / libs / signals / example / maximum.cpp
CommitLineData
7c673cae
FG
1// Boost.Signals library
2
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)
7
8// For more information, see http://www.boost.org
9
10#include <algorithm>
11#include <iostream>
12#include <boost/signals/signal2.hpp>
13
14template<typename T>
15struct maximum {
16 typedef T result_type;
17
18 template<typename InputIterator>
19 T operator()(InputIterator first, InputIterator last) const
20 {
21 if (first == last)
22 throw std::runtime_error("Cannot compute maximum of zero elements!");
23 return *std::max_element(first, last);
24 }
25};
26
27int main()
28{
29 boost::signal2<int, int, int, maximum<int> > sig_max;
30 sig_max.connect(std::plus<int>());
31 sig_max.connect(std::multiplies<int>());
32 sig_max.connect(std::minus<int>());
33 sig_max.connect(std::divides<int>());
34
35 std::cout << sig_max(5, 3) << std::endl; // prints 15
36
37 return 0;
38}