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

The MPL Reference Manual: single_view
Front Page / Sequences / Views / single_view

single_view

Synopsis

template<
      typename T
    >
struct single_view
{
    // unspecified
    // ...
};

Description

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

Parameters

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
single_view
single_view::type
A single-element Random Access Sequence v such that front::type is identical to x.
size::type The size of v; size::value == 1; see Random Access Sequence.

Example

typedef single_view view;
typedef begin::type first;
typedef end::type last;

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

BOOST_MPL_ASSERT_RELATION( size::value, ==, 1 );