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 an old version of boost. Click here for the latest version's documentation home page.

[Home]single_view

Synopsis

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

Description

Allows one to represent an arbitrary type T as a single-element sequence.

Definition

#include "boost/mpl/single_view.hpp"

Parameters

 Parameter  Requirement  Description  
TA typeThe type to be wrapped in a sequence.

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition 
typedef single_view<T> s;A model of Sequences is a random-access, single-element sequence such as front<s>::type is identical to Tsize<s>::type::value == 1, boost::same_as<front<s>::type,T>::value == true.

Complexity

Amortized constant time.

Example

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

BOOST_MPL_ASSERT_IS_SAME(first::type,int); BOOST_MPL_ASSERT_IS_SAME(first::next,last); BOOST_MPL_ASSERT_IS_SAME(last::prior,first);

BOOST_STATIC_ASSERT(size<view>::type::value == 1);

See also

Sequences, transform_view, filter_view, joint_view, zip_view


Table of Contents
Last edited March 10, 2003 5:19 am