fix doc example typo
[boost.git] / boost / last_value.hpp
blob183a739eadcae3391856feccdebfe72a851d4392
1 // last_value function object (documented as part of Boost.Signals)
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/libs/signals
10 #ifndef BOOST_LAST_VALUE_HPP
11 #define BOOST_LAST_VALUE_HPP
13 #include <cassert>
14 #include <boost/config.hpp>
16 namespace boost {
17 template<typename T>
18 struct last_value {
19 typedef T result_type;
21 template<typename InputIterator>
22 T operator()(InputIterator first, InputIterator last) const
24 assert(first != last);
25 T value = *first++;
26 while (first != last)
27 value = *first++;
28 return value;
32 template<>
33 struct last_value<void> {
34 #ifdef BOOST_NO_VOID_RETURNS
35 struct unusable {};
37 public:
38 typedef unusable result_type;
39 #else
40 public:
41 typedef void result_type;
42 #endif // BOOST_NO_VOID_RETURNS
44 template<typename InputIterator>
45 result_type
46 operator()(InputIterator first, InputIterator last) const
48 while (first != last)
49 *first++;
50 return result_type();
54 #endif // BOOST_SIGNALS_LAST_VALUE_HPP