1 // last_value function object (documented as part of Boost.Signals)
3 // Copyright Frank Mori Hess 2007.
4 // Copyright Douglas Gregor 2001-2003. Use, modification and
5 // distribution is subject to the Boost Software License, Version
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // For more information, see http://www.boost.org
11 #ifndef BOOST_SIGNALS2_LAST_VALUE_HPP
12 #define BOOST_SIGNALS2_LAST_VALUE_HPP
14 #include <boost/core/no_exceptions_support.hpp>
15 #include <boost/optional.hpp>
16 #include <boost/signals2/expired_slot.hpp>
17 #include <boost/throw_exception.hpp>
23 // no_slots_error is thrown when we are unable to generate a return value
24 // due to no slots being connected to the signal.
25 class no_slots_error: public std::exception
28 virtual const char* what() const throw() {return "boost::signals2::no_slots_error";}
34 typedef T result_type;
36 template<typename InputIterator>
37 T operator()(InputIterator first, InputIterator last) const
41 boost::throw_exception(no_slots_error());
50 BOOST_CATCH(const expired_slot &) {}
54 if(value) return value.get();
55 throw no_slots_error();
60 class last_value<void> {
62 typedef void result_type;
63 template<typename InputIterator>
64 result_type operator()(InputIterator first, InputIterator last) const
72 BOOST_CATCH(const expired_slot &) {}
79 } // namespace signals2
81 #endif // BOOST_SIGNALS2_LAST_VALUE_HPP