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
front
Description

Returns the first element in the sequence.

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

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

Parameter

Requirement

Description

seq

Model of Forward Sequence

The sequence we wish to investigate.

Expression Semantics
front(seq);

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

Precondition: empty(seq) == false

Semantics: Returns the first element in the sequence.

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

PrevUpHomeNext