File indexing completed on 2025-12-16 10:08:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_SIGNALS2_OPTIONAL_LAST_VALUE_HPP
0012 #define BOOST_SIGNALS2_OPTIONAL_LAST_VALUE_HPP
0013
0014 #include <boost/core/no_exceptions_support.hpp>
0015 #include <boost/move/utility_core.hpp>
0016 #include <boost/optional.hpp>
0017 #include <boost/signals2/expired_slot.hpp>
0018
0019 namespace boost {
0020 namespace signals2 {
0021
0022 template<typename T>
0023 class optional_last_value
0024 {
0025 public:
0026 typedef optional<T> result_type;
0027
0028 template<typename InputIterator>
0029 optional<T> operator()(InputIterator first, InputIterator last) const
0030 {
0031 optional<T> value;
0032 while (first != last)
0033 {
0034 BOOST_TRY
0035 {
0036 value = boost::move_if_not_lvalue_reference<T>(*first);
0037 }
0038 BOOST_CATCH(const expired_slot &) {}
0039 BOOST_CATCH_END
0040 ++first;
0041 }
0042 return value;
0043 }
0044 };
0045
0046 template<>
0047 class optional_last_value<void>
0048 {
0049 public:
0050 typedef void result_type;
0051 template<typename InputIterator>
0052 result_type operator()(InputIterator first, InputIterator last) const
0053 {
0054 while (first != last)
0055 {
0056 BOOST_TRY
0057 {
0058 *first;
0059 }
0060 BOOST_CATCH(const expired_slot &) {}
0061 BOOST_CATCH_END
0062 ++first;
0063 }
0064 return;
0065 }
0066 };
0067 }
0068 }
0069 #endif