• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Sequences/Views//single_view
2
3single_view
4===========
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11    template<
12          typename T
13        >
14    struct single_view
15    {
16        // |unspecified|
17        // |...|
18    };
19
20
21
22Description
23-----------
24
25A view onto an arbitrary type ``T`` as on a single-element sequence.
26
27
28Header
29------
30
31.. parsed-literal::
32
33    #include <boost/mpl/single_view.hpp>
34
35
36Model of
37--------
38
39* |Random Access Sequence|
40
41
42Parameters
43----------
44
45+---------------+-------------------+-----------------------------------------------+
46| Parameter     | Requirement       | Description                                   |
47+===============+===================+===============================================+
48| ``T``         | Any type          | The type to be wrapped in a sequence.         |
49+---------------+-------------------+-----------------------------------------------+
50
51
52Expression semantics
53--------------------
54
55|Semantics disclaimer...| |Random Access Sequence|.
56
57In the following table, ``v`` is an instance of ``single_view``, ``x`` is an arbitrary type.
58
59+-------------------------------+-----------------------------------------------------------+
60| Expression                    | Semantics                                                 |
61+===============================+===========================================================+
62| .. parsed-literal::           | A single-element |Random Access Sequence| ``v`` such that |
63|                               | ``front<v>::type`` is identical to ``x``.                 |
64|    single_view<x>             |                                                           |
65|    single_view<x>::type       |                                                           |
66+-------------------------------+-----------------------------------------------------------+
67| ``size<v>::type``             | The size of ``v``; ``size<v>::value == 1``;               |
68|                               | see |Random Access Sequence|.                             |
69+-------------------------------+-----------------------------------------------------------+
70
71Example
72-------
73
74.. parsed-literal::
75
76    typedef single_view<int> view;
77    typedef begin<view>::type first;
78    typedef end<view>::type last;
79
80    BOOST_MPL_ASSERT(( is_same< deref<first>::type,int > ));
81    BOOST_MPL_ASSERT(( is_same< next<first>::type,last > ));
82    BOOST_MPL_ASSERT(( is_same< prior<last>::type,first > ));
83
84    BOOST_MPL_ASSERT_RELATION( size<view>::value, ==, 1 );
85
86
87See also
88--------
89
90|Sequences|, |Views|, |iterator_range|, |filter_view|, |transform_view|, |joint_view|, |zip_view|
91
92
93.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
94   Distributed under the Boost Software License, Version 1.0. (See accompanying
95   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
96