mirror of
https://github.com/boostorg/mpl.git
synced 2026-01-26 08:52:21 +01:00
62 lines
2.6 KiB
HTML
62 lines
2.6 KiB
HTML
<!doctype html public "-//ietf//dtd html//en">
|
|
<html><head><title>boost::mpl::single_view</title>
|
|
<link rel="stylesheet" href="../mpl_wiki.css">
|
|
</head><body bgcolor="white">
|
|
<h1><a href="../Table_of_Contents.html"><img src="../mpl_logo.jpg" alt="[Home]" border=0 align="right"></a>single_view</h1><h3>Synopsis</h3>
|
|
<p>
|
|
<pre>
|
|
template<
|
|
typename T
|
|
>
|
|
struct single_view
|
|
{
|
|
<span class="cxx-comment">// unspecified</span>
|
|
};
|
|
</pre>
|
|
<p>
|
|
<h3>Description</h3>
|
|
<p>
|
|
Allows one to represent an arbitrary type <code>T</code> as a single-element sequence.
|
|
<p>
|
|
<h3>Definition</h3>
|
|
<p>
|
|
<pre>
|
|
#include "<a href="../../../../../boost/mpl/single_view.hpp">boost/mpl/single_view.hpp</a>"
|
|
</pre>
|
|
<p>
|
|
<h3>Parameters</h3>
|
|
<table border="1">
|
|
<tr><th> Parameter </th><th> Requirement </th><th> Description </th></tr>
|
|
<tr><td><code>T</code></td><td>A type</td><td>The type to be wrapped in a sequence. </td></tr>
|
|
</table>
|
|
<p>
|
|
<h3>Expression semantics</h3>
|
|
<p>
|
|
<table border="1">
|
|
<tr><th> Expression </th><th> Expression type </th><th> Precondition </th><th> Semantics </th><th> Postcondition </th></tr>
|
|
<tr><td><code>typedef single_view<T> s;</code></td><td>A model of <a href="../Sequence.html">Sequence</a></td><td></td><td><code>s</code> is a random-access, single-element sequence such as <code><a href="../Reference/front.html">front</a><s>::type</code> is identical to <code>T</code></td><td><code><a href="../Reference/size.html">size</a><s>::type::value == 1, boost::same_as<<a href="../Reference/front.html">front</a><s>::type,T>::value == true</code>. </td></tr>
|
|
</table>
|
|
<p>
|
|
<h3>Complexity</h3>
|
|
<p>
|
|
Amortized constant time.
|
|
<p>
|
|
<h3>Example</h3>
|
|
<p>
|
|
<pre>
|
|
typedef single_view<int> view;
|
|
typedef <a href="../Reference/begin.html">begin</a><view>::type first;
|
|
typedef <a href="../Reference/end.html">end</a><view>::type last;
|
|
<p>
|
|
BOOST_MPL_ASSERT_IS_SAME(first::type,int);
|
|
BOOST_MPL_ASSERT_IS_SAME(first::next,last);
|
|
BOOST_MPL_ASSERT_IS_SAME(last::prior,first);
|
|
<p>
|
|
BOOST_STATIC_ASSERT(size<view>::type::value == 1);
|
|
</pre>
|
|
<p>
|
|
<h3>See also</h3>
|
|
<p>
|
|
<a href="../Sequences.html">Sequences</a>, <code><a href="../Reference/transform_view.html">transform_view</a></code>, <code><a href="../Reference/filter_view.html">filter_view</a></code>, <code><a href="../Reference/joint_view.html">joint_view</a></code>, <code><a href="../Reference/zip_view.html">zip_view</a></code>
|
|
<p><hr>
|
|
<a href="../Table_of_Contents.html">Table of Contents</a><br>Last edited March 10, 2003 5:19 am</body></html> |