| Home | Libraries | People | FAQ | More

## 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 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.

### Specializations

- Class optional_last_value<void>