Mercurial > hg > vamp-build-and-test
annotate DEPENDENCIES/generic/include/boost/last_value.hpp @ 125:34e428693f5d vext
Vext -> Repoint
author | Chris Cannam |
---|---|
date | Thu, 14 Jun 2018 11:15:39 +0100 |
parents | 2665513ce2d3 |
children |
rev | line source |
---|---|
Chris@16 | 1 // last_value function object (documented as part of Boost.Signals) |
Chris@16 | 2 |
Chris@16 | 3 // Copyright Douglas Gregor 2001-2003. Use, modification and |
Chris@16 | 4 // distribution is subject to the Boost Software License, Version |
Chris@16 | 5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
Chris@16 | 6 // http://www.boost.org/LICENSE_1_0.txt) |
Chris@16 | 7 |
Chris@16 | 8 // For more information, see http://www.boost.org/libs/signals |
Chris@16 | 9 |
Chris@16 | 10 #ifndef BOOST_LAST_VALUE_HPP |
Chris@16 | 11 #define BOOST_LAST_VALUE_HPP |
Chris@16 | 12 |
Chris@16 | 13 #include <cassert> |
Chris@16 | 14 #include <boost/config.hpp> |
Chris@16 | 15 |
Chris@16 | 16 namespace boost { |
Chris@16 | 17 template<typename T> |
Chris@16 | 18 struct last_value { |
Chris@16 | 19 typedef T result_type; |
Chris@16 | 20 |
Chris@16 | 21 template<typename InputIterator> |
Chris@16 | 22 T operator()(InputIterator first, InputIterator last) const |
Chris@16 | 23 { |
Chris@16 | 24 assert(first != last); |
Chris@16 | 25 T value = *first++; |
Chris@16 | 26 while (first != last) |
Chris@16 | 27 value = *first++; |
Chris@16 | 28 return value; |
Chris@16 | 29 } |
Chris@16 | 30 }; |
Chris@16 | 31 |
Chris@16 | 32 template<> |
Chris@16 | 33 struct last_value<void> { |
Chris@16 | 34 #ifdef BOOST_NO_VOID_RETURNS |
Chris@16 | 35 struct unusable {}; |
Chris@16 | 36 |
Chris@16 | 37 public: |
Chris@16 | 38 typedef unusable result_type; |
Chris@16 | 39 #else |
Chris@16 | 40 public: |
Chris@16 | 41 typedef void result_type; |
Chris@16 | 42 #endif // BOOST_NO_VOID_RETURNS |
Chris@16 | 43 |
Chris@16 | 44 template<typename InputIterator> |
Chris@16 | 45 result_type |
Chris@16 | 46 operator()(InputIterator first, InputIterator last) const |
Chris@16 | 47 { |
Chris@16 | 48 while (first != last) |
Chris@16 | 49 *first++; |
Chris@16 | 50 return result_type(); |
Chris@16 | 51 } |
Chris@16 | 52 }; |
Chris@16 | 53 } |
Chris@16 | 54 #endif // BOOST_SIGNALS_LAST_VALUE_HPP |