mirror of
https://github.com/boostorg/mpl.git
synced 2026-08-07 14:14:24 +02:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ebe0e7b935 | |||
| 3e3b4aeef2 | |||
| 6e78a8f0f4 | |||
| 161b05edfb | |||
| 3a4c350910 |
Executable → Regular
+17
-5
@@ -12,7 +12,7 @@
|
||||
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./classes.html" class="navigation-link">Classes</a> / <a href="./set.html" class="navigation-link">set</a></td>
|
||||
</tr></table><div class="header-separator"></div>
|
||||
<div class="section" id="set">
|
||||
<h1><a class="toc-backref" href="./classes.html#id1409">set</a></h1>
|
||||
<h1><a class="toc-backref" href="./classes.html#id1410">set</a></h1>
|
||||
<div class="section" id="id72">
|
||||
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
|
||||
<p><tt class="literal"><span class="pre"><a href="./set.html" class="identifier">set</a></span></tt> is a <a class="reference internal" href="./variadic-sequence.html">variadic</a>, <a class="reference internal" href="./associative-sequence.html">associative</a>, <a class="reference internal" href="./extensible-associative-sequence.html">extensible</a> sequence of types that
|
||||
@@ -52,7 +52,8 @@ A <tt class="literal"><span class="pre"><a href="./set.html" class="identifier">
|
||||
<div class="section" id="id77">
|
||||
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
|
||||
<p>In the following table, <tt class="literal"><span class="pre">s</span></tt> is an instance of <tt class="literal"><span class="pre"><a href="./set.html" class="identifier">set</a></span></tt>, <tt class="literal"><span class="pre">pos</span></tt> is an iterator into <tt class="literal"><span class="pre">s</span></tt>,
|
||||
and <tt class="literal"><span class="pre">x</span></tt>, <tt class="literal"><span class="pre">k</span></tt>, and <em>t</em><sub>1</sub>,<em>t</em><sub>2</sub>,... <em>t</em><sub>n</sub> are arbitrary types.</p>
|
||||
and <tt class="literal"><span class="pre">x</span></tt>, <tt class="literal"><span class="pre">k</span></tt>, and <em>t</em><sub>1</sub>,<em>t</em><sub>2</sub>,... <em>t</em><sub>n</sub> is a set of <em>unique</em> arbitrary types. [<em>Note:</em> See <a class="reference internal" href="./set.html#nonunique-set-example">below</a> for
|
||||
an example of how to construct a <tt class="literal"><span class="pre"><a href="./set.html" class="identifier">set</a></span></tt> from a list of potentially non-unique types — <em>end note</em>]</p>
|
||||
<table border="1" class="docutils table">
|
||||
<colgroup>
|
||||
<col width="40%" />
|
||||
@@ -151,8 +152,9 @@ the key <tt class="literal"><span class="pre">k</span></tt> in <tt class="litera
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="section" id="id78">
|
||||
<div class="section" id="id79">
|
||||
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
|
||||
<p>Basic <tt class="literal"><span class="pre"><a href="./set.html" class="identifier">set</a></span></tt> invariants:</p>
|
||||
<pre class="literal-block">
|
||||
typedef <a href="./set.html" class="identifier">set</a>< int,long,double,<a href="./int.html" class="identifier">int_</a><5> > s;
|
||||
|
||||
@@ -164,8 +166,18 @@ typedef <a href="./set.html" class="identifier">set</a>< int,long,double,<a h
|
||||
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same< <a href="./at.html" class="identifier">at</a><s,<a href="./int.html" class="identifier">int_</a><5> >::type, <a href="./int.html" class="identifier">int_</a><5> > ));
|
||||
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same< <a href="./at.html" class="identifier">at</a><s,char>::type, <a href="./void.html" class="identifier">void_</a> > ));
|
||||
</pre>
|
||||
<p id="nonunique-set-example">Constructing a <tt class="literal"><span class="pre"><a href="./set.html" class="identifier">set</a></span></tt> from a list of potentially non-unique types:</p>
|
||||
<pre class="literal-block">
|
||||
typedef <a href="./fold.html" class="identifier">fold</a><
|
||||
<a href="./vector.html" class="identifier">vector</a><int,int,long,long>
|
||||
, set0<>
|
||||
, <a href="./insert.html" class="identifier">insert</a><<a href="./placeholders.html" class="identifier">_1</a>,<a href="./placeholders.html" class="identifier">_2</a>>
|
||||
>::type s;
|
||||
|
||||
<a href="./assert-relation.html" class="identifier">BOOST_MPL_ASSERT_RELATION</a>( <a href="./size.html" class="identifier">size</a><s>::value, ==, 2 );
|
||||
</pre>
|
||||
</div>
|
||||
<div class="section" id="id79">
|
||||
<div class="section" id="id80">
|
||||
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
|
||||
<p><a class="reference internal" href="./sequences.html">Sequences</a>, <a class="reference internal" href="./variadic-sequence.html">Variadic Sequence</a>, <a class="reference internal" href="./associative-sequence.html">Associative Sequence</a>, <a class="reference internal" href="./extensible-associative-sequence.html">Extensible Associative Sequence</a>, <a class="reference internal" href="./set-c.html">set_c</a>, <a class="reference internal" href="./map.html">map</a>, <a class="reference internal" href="./vector.html">vector</a></p>
|
||||
<!-- Sequences/Classes//map |50 -->
|
||||
@@ -174,7 +186,7 @@ typedef <a href="./set.html" class="identifier">set</a>< int,long,double,<a h
|
||||
|
||||
<div class="footer-separator"></div>
|
||||
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./deque.html" class="navigation-link">Prev</a> <a href="./map.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./deque.html" class="navigation-link">Back</a> <a href="./map.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./classes.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
|
||||
<td><div class="copyright-footer"><div class="copyright">Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams</div>
|
||||
<td><div class="copyright-footer"><div class="copyright">Copyright © 2001-2011 Aleksey Gurtovoy and David Abrahams</div>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</div></td></tr></table></body>
|
||||
</html>
|
||||
|
||||
@@ -37,7 +37,10 @@ Expression semantics
|
||||
--------------------
|
||||
|
||||
In the following table, ``s`` is an instance of ``set``, ``pos`` is an iterator into ``s``,
|
||||
and ``x``, ``k``, and |t1...tn| are arbitrary types.
|
||||
and ``x``, ``k``, and |t1...tn| is a set of *unique* arbitrary types. [*Note:* See `below`__ for
|
||||
an example of how to construct a ``set`` from a list of potentially non-unique types |--| *end note*\]
|
||||
|
||||
__ nonunique-set-example_
|
||||
|
||||
+---------------------------------------+-----------------------------------------------------------+
|
||||
| Expression | Semantics |
|
||||
@@ -105,6 +108,8 @@ and ``x``, ``k``, and |t1...tn| are arbitrary types.
|
||||
Example
|
||||
-------
|
||||
|
||||
Basic ``set`` invariants:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
typedef set< int,long,double,int_<5> > s;
|
||||
@@ -118,12 +123,27 @@ Example
|
||||
BOOST_MPL_ASSERT(( is_same< at<s,char>::type, void\_ > ));
|
||||
|
||||
|
||||
.. _nonunique-set-example:
|
||||
|
||||
Constructing a ``set`` from a list of potentially non-unique types:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
typedef fold<
|
||||
vector<int,int,long,long>
|
||||
, set0<>
|
||||
, insert<_1,_2>
|
||||
>::type s;
|
||||
|
||||
BOOST_MPL_ASSERT_RELATION( size<s>::value, ==, 2 );
|
||||
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
|Sequences|, |Variadic Sequence|, |Associative Sequence|, |Extensible Associative Sequence|, |set_c|, |map|, |vector|
|
||||
|
||||
|
||||
.. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
|
||||
.. copyright:: Copyright © 2001-2011 Aleksey Gurtovoy and David Abrahams
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -644,6 +644,7 @@ td,
|
||||
table.table
|
||||
th
|
||||
{
|
||||
border: solid 1px #c7c7c7;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
|
||||
Executable → Regular
Executable → Regular
@@ -34,6 +34,9 @@
|
||||
#include <boost/config.hpp> // make sure 'size_t' is placed into 'std'
|
||||
#include <cstddef>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1700)
|
||||
#include <boost/mpl/if.hpp>
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x610)) \
|
||||
|| (BOOST_MPL_CFG_GCC != 0) \
|
||||
@@ -131,8 +134,38 @@ template< assert_::relations r, long x, long y > struct assert_relation {};
|
||||
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1700)
|
||||
|
||||
#if !defined(BOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER)
|
||||
template<class Pred>
|
||||
struct extract_assert_pred;
|
||||
|
||||
template<class Pred>
|
||||
struct extract_assert_pred<void(Pred)> { typedef Pred type; };
|
||||
|
||||
template<class Pred>
|
||||
struct eval_assert {
|
||||
typedef typename extract_assert_pred<Pred>::type P;
|
||||
typedef typename P::type p_type;
|
||||
typedef typename ::boost::mpl::if_c<p_type::value,
|
||||
AUX778076_ASSERT_ARG(assert<false>),
|
||||
failed ************ P::************
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<class Pred>
|
||||
struct eval_assert_not {
|
||||
typedef typename extract_assert_pred<Pred>::type P;
|
||||
typedef typename P::type p_type;
|
||||
typedef typename ::boost::mpl::if_c<!p_type::value,
|
||||
AUX778076_ASSERT_ARG(assert<false>),
|
||||
failed ************ ::boost::mpl::not_<P>::************
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
T make_assert_arg();
|
||||
|
||||
#elif !defined(BOOST_MPL_CFG_ASSERT_BROKEN_POINTER_TO_POINTER_TO_MEMBER)
|
||||
|
||||
template< bool > struct assert_arg_pred_impl { typedef int type; };
|
||||
template<> struct assert_arg_pred_impl<true> { typedef void* type; };
|
||||
@@ -211,6 +244,39 @@ assert_rel_arg( assert_relation<r,x,y> );
|
||||
|
||||
BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_CLOSE
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1700)
|
||||
|
||||
// BOOST_MPL_ASSERT((pred<x,...>))
|
||||
|
||||
#define BOOST_MPL_ASSERT(pred) \
|
||||
BOOST_MPL_AUX_ASSERT_CONSTANT( \
|
||||
std::size_t \
|
||||
, BOOST_PP_CAT(mpl_assertion_in_line_,BOOST_MPL_AUX_PP_COUNTER()) = sizeof( \
|
||||
boost::mpl::assertion_failed<false>( \
|
||||
boost::mpl::make_assert_arg< \
|
||||
typename boost::mpl::eval_assert<void pred>::type \
|
||||
>() \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
/**/
|
||||
|
||||
// BOOST_MPL_ASSERT_NOT((pred<x,...>))
|
||||
|
||||
#define BOOST_MPL_ASSERT_NOT(pred) \
|
||||
BOOST_MPL_AUX_ASSERT_CONSTANT( \
|
||||
std::size_t \
|
||||
, BOOST_PP_CAT(mpl_assertion_in_line_,BOOST_MPL_AUX_PP_COUNTER()) = sizeof( \
|
||||
boost::mpl::assertion_failed<false>( \
|
||||
boost::mpl::make_assert_arg< \
|
||||
typename boost::mpl::eval_assert_not<void pred>::type \
|
||||
>() \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
/**/
|
||||
|
||||
#else
|
||||
|
||||
// BOOST_MPL_ASSERT((pred<x,...>))
|
||||
|
||||
@@ -250,6 +316,8 @@ BOOST_MPL_AUX_ASSERT_CONSTANT( \
|
||||
/**/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// BOOST_MPL_ASSERT_RELATION(x, ==|!=|<=|<|>=|>, y)
|
||||
|
||||
#if defined(BOOST_MPL_CFG_ASSERT_USE_RELATION_NAMES)
|
||||
|
||||
Executable → Regular
@@ -71,6 +71,17 @@ struct her
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct nested : boost::mpl::true_ {
|
||||
BOOST_MPL_ASSERT(( boost::is_pointer<T*> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::is_same<void,T> ));
|
||||
BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 );
|
||||
BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
|
||||
};
|
||||
|
||||
BOOST_MPL_ASSERT(( nested<int> ));
|
||||
BOOST_MPL_ASSERT_NOT(( boost::mpl::not_<nested<unsigned> > ));
|
||||
|
||||
int main()
|
||||
{
|
||||
her<void> h;
|
||||
|
||||
Reference in New Issue
Block a user