Boost C++ Libraries

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

This is the documentation for a snapshot of the master branch, built from commit 0d0642aa30.
PrevUpHomeNext

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.

Synopsis

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

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

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

Description

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;

    Effects:

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

    Returns:

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

    Throws:

    Does not throw.


PrevUpHomeNext