Chris@16: // last_value function object (documented as part of Boost.Signals) Chris@16: Chris@16: // Copyright Douglas Gregor 2001-2003. Use, modification and Chris@16: // distribution is subject to the Boost Software License, Version Chris@16: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // For more information, see http://www.boost.org/libs/signals Chris@16: Chris@16: #ifndef BOOST_LAST_VALUE_HPP Chris@16: #define BOOST_LAST_VALUE_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: template Chris@16: struct last_value { Chris@16: typedef T result_type; Chris@16: Chris@16: template Chris@16: T operator()(InputIterator first, InputIterator last) const Chris@16: { Chris@16: assert(first != last); Chris@16: T value = *first++; Chris@16: while (first != last) Chris@16: value = *first++; Chris@16: return value; Chris@16: } Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct last_value { Chris@16: #ifdef BOOST_NO_VOID_RETURNS Chris@16: struct unusable {}; Chris@16: Chris@16: public: Chris@16: typedef unusable result_type; Chris@16: #else Chris@16: public: Chris@16: typedef void result_type; Chris@16: #endif // BOOST_NO_VOID_RETURNS Chris@16: Chris@16: template Chris@16: result_type Chris@16: operator()(InputIterator first, InputIterator last) const Chris@16: { Chris@16: while (first != last) Chris@16: *first++; Chris@16: return result_type(); Chris@16: } Chris@16: }; Chris@16: } Chris@16: #endif // BOOST_SIGNALS_LAST_VALUE_HPP