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 an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
back
Description

Returns the last element in the sequence.

Synopsis
template <typename Sequence>
typename result_of::back<Sequence>::type
back(Sequence& seq);

template <typename Sequence>
typename result_of::back<Sequence const>::type
back(Sequence const& seq);
Parameters

Parameter

Requirement

Description

seq

Model of Bidirectional Sequence

The sequence we wish to investigate.

Expression Semantics
back(seq);

Return type: Returns a reference to the last element in the sequence seq if seq is mutable and e = o, where e is the last element in the sequence, is a valid expression. Else, returns a type convertible to the last element in the sequence.

Precondition: empty(seq) == false

Semantics: Returns the last element in the sequence.

Header
#include <boost/fusion/sequence/intrinsic/back.hpp>
#include <boost/fusion/include/back.hpp>
Example
vector<int, int, int> v(1, 2, 3);
assert(back(v) == 3);

PrevUpHomeNext