Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.

Class template optional_last_value

boost::signals2::optional_last_value — Evaluate an InputIterator sequence and return a boost::optional which contains the last value in the sequence, or an empty boost::optional if the sequence was empty.


// In header: <boost/signals2/optional_last_value.hpp>

template<typename T> 
class optional_last_value {
  // types
  typedef boost::optional<T> result_type;

  // invocation
  template<typename InputIterator> 
    result_type operator()(InputIterator, InputIterator) const;


optional_last_value is the default Combiner template type for signals in the Boost.Signals2 library. The advantage of optional_last_value over signals2::last_value is that optional_last_value can return an empty boost::optional. rather than throwing an exception, when its InputIterator sequence is empty.

optional_last_value invocation

  1. template<typename InputIterator> 
      result_type operator()(InputIterator first, InputIterator last) const;


    Attempts to dereference every iterator in the sequence [first, last).


    The result of the last successful iterator dereference, wrapped in a boost::optional. The returned optional will be empty if no iterators were dereferenced.


    Does not throw.