PageRenderTime 39ms CodeModel.GetById 32ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/last_value.hpp

http://hadesmem.googlecode.com/
C++ Header | 54 lines | 39 code | 9 blank | 6 comment | 5 complexity | 9ed064c53e6f2162d1750d6a0d442dfc MD5 | raw file
 1// last_value function object (documented as part of Boost.Signals)
 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/libs/signals
 9
10#ifndef BOOST_LAST_VALUE_HPP
11#define BOOST_LAST_VALUE_HPP
12
13#include <cassert>
14#include <boost/config.hpp>
15
16namespace boost {
17  template<typename T>
18  struct last_value {
19    typedef T result_type;
20
21    template<typename InputIterator>
22    T operator()(InputIterator first, InputIterator last) const
23    {
24      assert(first != last);
25      T value = *first++;
26      while (first != last)
27        value = *first++;
28      return value;
29    }
30  };
31
32  template<>
33  struct last_value<void> {
34#ifdef BOOST_NO_VOID_RETURNS
35    struct unusable {};
36
37  public:
38    typedef unusable result_type;
39#else
40  public:
41    typedef void result_type;
42#endif // BOOST_NO_VOID_RETURNS
43
44    template<typename InputIterator>
45    result_type
46    operator()(InputIterator first, InputIterator last) const
47    {
48      while (first != last)
49        *first++;
50      return result_type();
51    }
52  };
53}
54#endif // BOOST_SIGNALS_LAST_VALUE_HPP