|
Boost : |
From: Ames Andreas (Andreas.Ames_at_[hidden])
Date: 2005-09-26 12:29:05
Hello all,
I have the problem that signal's default combiner last_value is OOTB
only usable with non-empty signals, unless the return type is void.
The attached patch tries to circumvent this by returning an
optional<T> instead of a T.
cheers,
aa
-- Andreas Ames | Programmer | Comergo GmbH | Voice: +49 69 7505 3213 | andreas . ames AT comergo . com
Index: boost/boost/last_value.hpp
===================================================================
RCS file: /cc/CVSGlobal/tools/extern/boost/boost/last_value.hpp,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 last_value.hpp
--- last_value.hpp 2005/08/09 03:52:52 1.1.1.1
+++ last_value.hpp 2005/09/26 17:22:32
@@ -12,16 +12,17 @@
#include <cassert>
+#include <boost/optional.hpp>
+
namespace boost {
template<typename T>
struct last_value {
- typedef T result_type;
+ typedef optional<T> result_type;
template<typename InputIterator>
- T operator()(InputIterator first, InputIterator last) const
+ optional<T> operator()(InputIterator first, InputIterator last) const
{
- assert(first != last);
- T value = *first++;
+ optional<T> value;
while (first != last)
value = *first++;
return value;
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk