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

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
Front Page / Sequences / Views / single_view



      typename T
struct single_view
    // unspecified
    // ...


A view onto an arbitrary type T as on a single-element sequence.


#include <boost/mpl/single_view.hpp>

Model of


Parameter Requirement Description
T Any type The type to be wrapped in a sequence.

Expression semantics

The semantics of an expression are defined only where they differ from, or are not defined in Random Access Sequence.

In the following table, v is an instance of single_view, x is an arbitrary type.

Expression Semantics
A single-element Random Access Sequence v such that front<v>::type is identical to x.
size<v>::type The size of v; size<v>::value == 1; see Random Access Sequence.


typedef single_view<int> view;
typedef begin<view>::type first;
typedef end<view>::type last;

BOOST_MPL_ASSERT(( is_same< deref<first>::type,int > ));
BOOST_MPL_ASSERT(( is_same< next<first>::type,last > ));
BOOST_MPL_ASSERT(( is_same< prior<last>::type,first > ));

BOOST_MPL_ASSERT_RELATION( size<view>::value, ==, 1 );

See also

Sequences, Views, iterator_range, filter_view, transform_view, joint_view, zip_view