lyx_mirror/boost/boost/last_value.hpp
Lars Gullik Bjønnes 2349a51b12 update to boost 1.32.0
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9274 a592a061-630c-0410-9148-cb99ea01b6c8
2004-11-20 09:08:45 +00:00

49 lines
1.1 KiB
C++

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