123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #ifndef BOOST_LAST_VALUE_HPP
- #define BOOST_LAST_VALUE_HPP
- #include <cassert>
- #include <boost/config.hpp>
- 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> {
- #ifdef BOOST_NO_VOID_RETURNS
- struct unusable {};
- public:
- typedef unusable result_type;
- #else
- public:
- typedef void result_type;
- #endif
- template<typename InputIterator>
- result_type
- operator()(InputIterator first, InputIterator last) const
- {
- while (first != last)
- *first++;
- return result_type();
- }
- };
- }
- #endif
|