mirror of
https://github.com/boostorg/parameter.git
synced 2026-01-22 05:22:31 +00:00
Compare commits
139 Commits
boost-1.45
...
svn-branch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65bf84c0a0 | ||
|
|
359b3a5c3a | ||
|
|
522c1e33b0 | ||
|
|
298108e7ed | ||
|
|
ae3bfbad46 | ||
|
|
d8a61e4df7 | ||
|
|
82b5cc0208 | ||
|
|
91623e6241 | ||
|
|
4af5c63d46 | ||
|
|
1c2f56c672 | ||
|
|
08b0a74035 | ||
|
|
4c8725641d | ||
|
|
b91cd816c8 | ||
|
|
f9a2fba9ab | ||
|
|
55792af45f | ||
|
|
e054a75533 | ||
|
|
834f245953 | ||
|
|
ef9dfeb2d1 | ||
|
|
98bcbbad78 | ||
|
|
d9f0e42397 | ||
|
|
0a26a05500 | ||
|
|
2e725894c6 | ||
|
|
a4b2742095 | ||
|
|
2af6d0439e | ||
|
|
276d786ed9 | ||
|
|
7689b5b9d0 | ||
|
|
a28883d9ad | ||
|
|
45bac7b579 | ||
|
|
e4e6ba52c4 | ||
|
|
6bb4b0ef8b | ||
|
|
e0416b8343 | ||
|
|
f8a1b652bc | ||
|
|
f7611b8a1f | ||
|
|
493a8b28a5 | ||
|
|
32ec272b6d | ||
|
|
4c8c0cce93 | ||
|
|
8fc7ba81cc | ||
|
|
5b2b1a47f8 | ||
|
|
f3764c539e | ||
|
|
b67fbdff8f | ||
|
|
0e263f5602 | ||
|
|
3c815b31fe | ||
|
|
dbbe37b8c1 | ||
|
|
ce712b8f30 | ||
|
|
913fa2eb44 | ||
|
|
12c873d3e4 | ||
|
|
164c48c018 | ||
|
|
2ac8833532 | ||
|
|
6556e278c6 | ||
|
|
1a9e89cb8d | ||
|
|
6d53a2b914 | ||
|
|
c7296b9a05 | ||
|
|
6a5d61ce3c | ||
|
|
e887f199e0 | ||
|
|
e7bd42b07a | ||
|
|
b9248d774f | ||
|
|
763a09c5aa | ||
|
|
07987bc97c | ||
|
|
b59c238a83 | ||
|
|
9dfa5a8d9e | ||
|
|
3d0bdf694c | ||
|
|
b5c6e05ea0 | ||
|
|
cc2a478afc | ||
|
|
1dab8a1008 | ||
|
|
4facdaafc3 | ||
|
|
5190f65321 | ||
|
|
0335832574 | ||
|
|
b9f287ea52 | ||
|
|
28f98ecbf0 | ||
|
|
4e8c8ced0f | ||
|
|
5baef32925 | ||
|
|
cc8ca29980 | ||
|
|
e2405e2d00 | ||
|
|
1cba9bd634 | ||
|
|
e58e928af4 | ||
|
|
c3e842fc4c | ||
|
|
ab57984c04 | ||
|
|
a8dc2bbd25 | ||
|
|
bb838edb2f | ||
|
|
74b777612e | ||
|
|
ea4457878c | ||
|
|
1f3fb08086 | ||
|
|
702ca6af6e | ||
|
|
225a38b68a | ||
|
|
de756246e7 | ||
|
|
de67d5fe6d | ||
|
|
40332972ca | ||
|
|
47292301e7 | ||
|
|
7a5a21dacc | ||
|
|
04aaeef41d | ||
|
|
5a0bad4224 | ||
|
|
07f167eed3 | ||
|
|
b34aa49ceb | ||
|
|
f5dbd06b32 | ||
|
|
9bcd7c2fec | ||
|
|
7f2abce0d4 | ||
|
|
b7036ee04f | ||
|
|
36d25230e6 | ||
|
|
d298a327b5 | ||
|
|
8162166037 | ||
|
|
dbcf8de808 | ||
|
|
07893af4c5 | ||
|
|
2070231553 | ||
|
|
5b1971f1ef | ||
|
|
988bb4b365 | ||
|
|
64bfddc3a7 | ||
|
|
2a0397c1b2 | ||
|
|
decd9ac9fd | ||
|
|
a181afc699 | ||
|
|
a6db5788f6 | ||
|
|
d37e7cd513 | ||
|
|
6dd64214c2 | ||
|
|
96d3e0fd07 | ||
|
|
ac398b0e50 | ||
|
|
3f1f0657f6 | ||
|
|
abae0c8d21 | ||
|
|
892a599999 | ||
|
|
acbf69fdb6 | ||
|
|
566e886887 | ||
|
|
ae05e30eac | ||
|
|
310998435c | ||
|
|
647265bfd3 | ||
|
|
76af708b1f | ||
|
|
deb606ef59 | ||
|
|
721b294842 | ||
|
|
f40418cf9a | ||
|
|
b12dbd9f6a | ||
|
|
6087feef11 | ||
|
|
e7d652f208 | ||
|
|
51c3dd4cb1 | ||
|
|
8cf35658bd | ||
|
|
ee2b252418 | ||
|
|
45d320a434 | ||
|
|
76067ad5d2 | ||
|
|
15b0729181 | ||
|
|
23d30d9ea6 | ||
|
|
012e0abd22 | ||
|
|
225ee5072e | ||
|
|
384add2571 |
17
doc/README.txt
Normal file
17
doc/README.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
.. -*-rst-*-
|
||||
|
||||
.. Copyright David Abrahams 2009. 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)
|
||||
|
||||
To build the html::
|
||||
|
||||
bjam html
|
||||
|
||||
To test the code in this documentation:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
python ../../../tools/litre/tool.py `pwd`/index.rst --dump_dir=../test/literate
|
||||
cd ../test/literate
|
||||
bjam
|
||||
@@ -78,14 +78,14 @@ int x = '''); -->
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Authors:</th><td class="field-body">David Abrahams, Daniel Wallin</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Contact:</th><td class="field-body"><a class="reference external" href="mailto:dave@boost-consulting.com">dave@boost-consulting.com</a>, <a class="reference external" href="mailto:dalwan01@student.umu.se">dalwan01@student.umu.se</a></td>
|
||||
<tr class="field"><th class="field-name">Contact:</th><td class="field-body"><a class="reference external" href="mailto:dave@boost-consulting.com">dave@boost-consulting.com</a>, <a class="reference external" href="mailto:daniel@boostpro.com">daniel@boostpro.com</a></td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Organization:</th><td class="field-body"><a class="reference external" href="http://www.boost-consulting.com">Boost Consulting</a></td>
|
||||
<tr class="field"><th class="field-name">organization:</th><td class="field-body"><a class="reference external" href="http://www.boostpro.com">BoostPro Computing</a></td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Date:</th><td class="field-body">$Date: 2005/07/18 20:34:31 $</td>
|
||||
<tr class="field"><th class="field-name">date:</th><td class="field-body">$Date: 2005/07/17 19:53:01 $</td>
|
||||
</tr>
|
||||
<tr class="field"><th class="field-name">Copyright:</th><td class="field-body">Copyright David Abrahams, Daniel Wallin 2005.
|
||||
Distributed under the Boost Software License,
|
||||
<tr class="field"><th class="field-name">copyright:</th><td class="field-body">Copyright David Abrahams, Daniel Wallin
|
||||
2005-2009. 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">http://www.boost.org/LICENSE_1_0.txt</a>)</td>
|
||||
</tr>
|
||||
@@ -1026,7 +1026,7 @@ BOOST_PARAMETER_NAME(arg2)
|
||||
struct callable2
|
||||
{
|
||||
BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
|
||||
(void), operator(), tag, (required (arg1,(int))(arg2,(int))))
|
||||
(void), call, tag, (required (arg1,(int))(arg2,(int))))
|
||||
{
|
||||
std::cout << arg1 << ", " << arg2 << std::endl;
|
||||
}
|
||||
@@ -1034,7 +1034,9 @@ struct callable2
|
||||
</pre>
|
||||
<!-- @example.prepend('''
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>''') -->
|
||||
#include <iostream>
|
||||
using namespace boost::parameter;
|
||||
''') -->
|
||||
<!-- @test('compile') -->
|
||||
<p>These macros don't directly allow a function's interface to be
|
||||
separated from its implementation, but you can always forward
|
||||
@@ -1043,7 +1045,7 @@ arguments on to a separate implementation function:</p>
|
||||
struct callable2
|
||||
{
|
||||
BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
|
||||
(void), operator(), tag, (required (arg1,(int))(arg2,(int))))
|
||||
(void), call, tag, (required (arg1,(int))(arg2,(int))))
|
||||
{
|
||||
call_impl(arg1,arg2);
|
||||
}
|
||||
@@ -1055,8 +1057,33 @@ struct callable2
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
BOOST_PARAMETER_NAME(arg1)
|
||||
BOOST_PARAMETER_NAME(arg2)''') -->
|
||||
BOOST_PARAMETER_NAME(arg2)
|
||||
using namespace boost::parameter;
|
||||
''') -->
|
||||
<!-- @test('compile') -->
|
||||
<div class="section" id="static-member-functions">
|
||||
<h3>2.2.1 Static Member Functions</h3>
|
||||
<p>To expose a static member function, simply insert the keyword
|
||||
“<tt class="docutils literal"><span class="pre">static</span></tt>” before the function name:</p>
|
||||
<pre class="literal-block">
|
||||
BOOST_PARAMETER_NAME(arg1)
|
||||
|
||||
struct somebody
|
||||
{
|
||||
BOOST_PARAMETER_MEMBER_FUNCTION(
|
||||
(void), <strong>static</strong> f, tag, (optional (arg1,(int),0)))
|
||||
{
|
||||
std::cout << arg1 << std::endl;
|
||||
}
|
||||
};
|
||||
</pre>
|
||||
<!-- @example.prepend('''
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
using namespace boost::parameter;
|
||||
''') -->
|
||||
<!-- @test('compile') -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="parameter-enabled-constructors">
|
||||
<h2><a class="toc-backref" href="#id29">2.3 Parameter-Enabled Constructors</a></h2>
|
||||
@@ -1224,10 +1251,10 @@ namespace boost { namespace python {
|
||||
using boost::mpl::_;
|
||||
|
||||
typedef parameter::parameters<
|
||||
required<tag::class_type, is_class<_> >
|
||||
, optional<tag::base_list, mpl::is_sequence<_> >
|
||||
, optional<tag::held_type>
|
||||
, optional<tag::copyable>
|
||||
required<tag::class_type, boost::is_class<_> >
|
||||
, parameter::optional<tag::base_list, mpl::is_sequence<_> >
|
||||
, parameter::optional<tag::held_type>
|
||||
, parameter::optional<tag::copyable>
|
||||
> class_signature;
|
||||
|
||||
}}
|
||||
@@ -1236,6 +1263,7 @@ typedef parameter::parameters<
|
||||
#include <boost/parameter.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <memory>
|
||||
|
||||
using namespace boost::parameter;
|
||||
@@ -1255,11 +1283,13 @@ struct bases
|
||||
</div>
|
||||
<div class="section" id="argument-packs-and-parameter-extraction">
|
||||
<span id="binding-intro"></span><h4>2.4.1.4 Argument Packs and Parameter Extraction</h4>
|
||||
<p>Next, within the body of <tt class="docutils literal"><span class="pre">class_</span></tt> , we use the <span class="concept">ParameterSpec</span>'s nested <tt class="docutils literal"><span class="pre">::bind<</span> <span class="pre">…</span> <span class="pre">></span></tt> template to bundle the actual arguments
|
||||
into an <a class="reference external" href="reference.html#argumentpack"><span class="concept">ArgumentPack</span></a> type, and then use the library's <tt class="docutils literal"><span class="pre">binding<</span>
|
||||
<span class="pre">…</span> <span class="pre">></span></tt> metafunction to extract “logical parameters”. Note that
|
||||
defaults are specified by supplying an optional third argument to
|
||||
<tt class="docutils literal"><span class="pre">binding<</span> <span class="pre">…</span> <span class="pre">></span></tt>:</p>
|
||||
<p>Next, within the body of <tt class="docutils literal"><span class="pre">class_</span></tt> , we use the <span class="concept">ParameterSpec</span>'s
|
||||
nested <tt class="docutils literal"><span class="pre">::bind<</span> <span class="pre">…</span> <span class="pre">></span></tt> template to bundle the actual arguments into an
|
||||
<a class="reference external" href="reference.html#argumentpack"><span class="concept">ArgumentPack</span></a> type, and then use the library's <tt class="docutils literal"><span class="pre">value_type<</span> <span class="pre">…</span> <span class="pre">></span></tt>
|
||||
metafunction to extract “logical parameters”. <tt class="docutils literal"><span class="pre">value_type<</span> <span class="pre">…</span> <span class="pre">></span></tt> is
|
||||
a lot like <tt class="docutils literal"><span class="pre">binding<</span> <span class="pre">…</span> <span class="pre">></span></tt>, but no reference is added to the actual
|
||||
argument type. Note that defaults are specified by passing it an
|
||||
optional third argument:</p>
|
||||
<pre class="literal-block">
|
||||
namespace boost { namespace python {
|
||||
|
||||
@@ -1277,16 +1307,16 @@ struct class_
|
||||
args;
|
||||
|
||||
// Extract first logical parameter.
|
||||
typedef typename parameter::binding<
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::class_type>::type class_type;
|
||||
|
||||
typedef typename parameter::binding<
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::base_list, bases<> >::type base_list;
|
||||
|
||||
typedef typename parameter::binding<
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::held_type, class_type>::type held_type;
|
||||
|
||||
typedef typename parameter::binding<
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::copyable, void>::type copyable;
|
||||
};
|
||||
|
||||
@@ -1381,12 +1411,12 @@ parameters deducible:</p>
|
||||
typedef parameter::parameters<
|
||||
required<tag::class_type, is_class<_> >
|
||||
|
||||
, optional<
|
||||
, parameter::optional<
|
||||
deduced<tag::base_list>
|
||||
, is_base_and_derived<detail::bases_base,_>
|
||||
>
|
||||
|
||||
, optional<
|
||||
, parameter::optional<
|
||||
deduced<tag::held_type>
|
||||
, mpl::not_<
|
||||
mpl::or_<
|
||||
@@ -1396,11 +1426,12 @@ typedef parameter::parameters<
|
||||
>
|
||||
>
|
||||
|
||||
, optional<deduced<tag::copyable>, is_same<noncopyable,_> >
|
||||
, parameter::optional<deduced<tag::copyable>, is_same<noncopyable,_> >
|
||||
|
||||
> class_signature;
|
||||
</pre>
|
||||
<!-- @example.prepend('''
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
namespace boost { namespace python {''') -->
|
||||
<!-- @example.append('''
|
||||
template <
|
||||
@@ -1417,16 +1448,16 @@ struct class_
|
||||
args;
|
||||
|
||||
// Extract first logical parameter.
|
||||
typedef typename parameter::binding<
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::class_type>::type class_type;
|
||||
|
||||
typedef typename parameter::binding<
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::base_list, bases<> >::type base_list;
|
||||
|
||||
typedef typename parameter::binding<
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::held_type, class_type>::type held_type;
|
||||
|
||||
typedef typename parameter::binding<
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::copyable, void>::type copyable;
|
||||
};
|
||||
|
||||
@@ -1613,15 +1644,13 @@ int main()
|
||||
<p>Occasionally one needs to deduce argument types without an extra
|
||||
layer of function call. For example, suppose we wanted to return
|
||||
twice the value of the <tt class="docutils literal"><span class="pre">index</span></tt> parameter? In that
|
||||
case we can use the <tt class="docutils literal"><span class="pre">binding<</span> <span class="pre">…</span> <span class="pre">></span></tt> metafunction introduced
|
||||
case we can use the <tt class="docutils literal"><span class="pre">value_type<</span> <span class="pre">…</span> <span class="pre">></span></tt> metafunction introduced
|
||||
<a class="reference internal" href="#binding-intro">earlier</a>:</p>
|
||||
<pre class="literal-block">
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
template <class ArgumentPack>
|
||||
typename remove_reference<
|
||||
typename parameter::binding<ArgumentPack, tag::index, int>::type
|
||||
>::type
|
||||
typename parameter::value_type<ArgumentPack, tag::index, int>::type
|
||||
twice_index(ArgumentPack const& args)
|
||||
{
|
||||
return 2 * args[_index|42];
|
||||
@@ -1635,32 +1664,16 @@ int six = twice_index(_index = 3);
|
||||
#include <cassert>
|
||||
|
||||
namespace parameter = boost::parameter;
|
||||
using boost::remove_reference;''') -->
|
||||
<p>Note that the <tt class="docutils literal"><span class="pre">remove_reference<</span> <span class="pre">…</span> <span class="pre">></span></tt> dance is necessary because
|
||||
<tt class="docutils literal"><span class="pre">binding<</span> <span class="pre">…</span> <span class="pre">></span></tt> will return a reference type when the argument
|
||||
is bound in the argument pack. If we don't strip the reference we
|
||||
end up returning a reference to the temporary created in the <tt class="docutils literal"><span class="pre">2</span> <span class="pre">*</span> <span class="pre">…</span></tt>
|
||||
expression. A convenient shortcut would be to use the <tt class="docutils literal"><span class="pre">value_type<</span> <span class="pre">…</span> <span class="pre">></span></tt>
|
||||
metafunction:</p>
|
||||
<pre class="literal-block">
|
||||
template <class ArgumentPack>
|
||||
typename <strong>parameter::value_type<ArgumentPack, tag::index, int></strong>::type
|
||||
twice_index(ArgumentPack const& args)
|
||||
{
|
||||
return 2 * args[_index|42];
|
||||
}
|
||||
</pre>
|
||||
<!-- @example.wrap('namespace with_value_type {', '''
|
||||
int six = twice_index(_index = 3);
|
||||
}''') -->
|
||||
<!-- TODO: binding<> returns a reference. We should use value_type<> here. -->
|
||||
''') -->
|
||||
<!-- @example.append('''
|
||||
int main()
|
||||
{
|
||||
assert(six == 6);
|
||||
assert(with_value_type::six == 6);
|
||||
}''') -->
|
||||
<!-- @test('run', howmany='all') -->
|
||||
<p>Note that if we had used <tt class="docutils literal"><span class="pre">binding<</span> <span class="pre">…</span> <span class="pre">></span></tt> rather than <tt class="docutils literal"><span class="pre">value_type<</span> <span class="pre">…</span>
|
||||
<span class="pre">></span></tt>, we would end up returning a reference to the temporary created in
|
||||
the <tt class="docutils literal"><span class="pre">2</span> <span class="pre">*</span> <span class="pre">…</span></tt> expression.</p>
|
||||
</div>
|
||||
<div class="section" id="lazy-default-computation">
|
||||
<h3>3.2.3 Lazy Default Computation</h3>
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
|
||||
<title>The Boost Parameter Library Python Binding Documentation</title>
|
||||
<meta name="authors" content="Daniel Wallin" />
|
||||
<meta name="organization" content="Boost Consulting" />
|
||||
<meta name="date" content="2008-03-22" />
|
||||
<meta name="copyright" content="Copyright David Abrahams, Daniel Wallin 2005. 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)" />
|
||||
<meta name="authors" content="David Abrahams Daniel Wallin" />
|
||||
<meta name="organization" content="BoostPro Computing" />
|
||||
<meta name="date" content="2009-01-29" />
|
||||
<meta name="copyright" content="Copyright David Abrahams, Daniel Wallin 2005-2009. 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)" />
|
||||
<link rel="stylesheet" href="rst.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
@@ -19,16 +19,17 @@
|
||||
<col class="docinfo-content" />
|
||||
<tbody valign="top">
|
||||
<tr><th class="docinfo-name">Authors:</th>
|
||||
<td>Daniel Wallin</td></tr>
|
||||
<td>David Abrahams
|
||||
<br />Daniel Wallin</td></tr>
|
||||
<tr><th class="docinfo-name">Contact:</th>
|
||||
<td><a class="first last reference external" href="mailto:dalwan01@student.umu.se">dalwan01@student.umu.se</a></td></tr>
|
||||
<td><a class="first reference external" href="mailto:dave@boost-consulting.com">dave@boost-consulting.com</a>, <a class="last reference external" href="mailto:daniel@boostpro.com">daniel@boostpro.com</a></td></tr>
|
||||
<tr><th class="docinfo-name">Organization:</th>
|
||||
<td><a class="first last reference external" href="http://www.boost-consulting.com">Boost Consulting</a></td></tr>
|
||||
<td><a class="first last reference external" href="http://www.boostpro.com">BoostPro Computing</a></td></tr>
|
||||
<tr><th class="docinfo-name">Date:</th>
|
||||
<td>2008-03-22</td></tr>
|
||||
<td>2009-01-29</td></tr>
|
||||
<tr><th class="docinfo-name">Copyright:</th>
|
||||
<td>Copyright David Abrahams, Daniel Wallin
|
||||
2005. Distributed under the Boost Software License,
|
||||
2005-2009. 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">http://www.boost.org/LICENSE_1_0.txt</a>)</td></tr>
|
||||
</tbody>
|
||||
@@ -779,7 +780,7 @@ specialization</em>.</p>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<hr class="footer" />
|
||||
Generated on: 2008-06-26 21:51 UTC.
|
||||
Generated on: 2009-01-30 21:27 UTC.
|
||||
Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
|
||||
|
||||
</div>
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
|
||||
<title>The Boost Parameter Library Reference Documentation</title>
|
||||
<meta name="authors" content="David Abrahams Daniel Wallin" />
|
||||
<meta name="organization" content="Boost Consulting" />
|
||||
<meta name="organization" content="BoostPro Computing" />
|
||||
<meta name="date" content="2005-07-17" />
|
||||
<meta name="copyright" content="Copyright David Abrahams, Daniel Wallin 2005. 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)" />
|
||||
<meta name="copyright" content="Copyright David Abrahams, Daniel Wallin 2005-2009. 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)" />
|
||||
<link rel="stylesheet" href="rst.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
@@ -22,14 +22,14 @@
|
||||
<td>David Abrahams
|
||||
<br />Daniel Wallin</td></tr>
|
||||
<tr><th class="docinfo-name">Contact:</th>
|
||||
<td><a class="first reference external" href="mailto:dave@boost-consulting.com">dave@boost-consulting.com</a>, <a class="last reference external" href="mailto:dalwan01@student.umu.se">dalwan01@student.umu.se</a></td></tr>
|
||||
<td><a class="first reference external" href="mailto:dave@boost-consulting.com">dave@boost-consulting.com</a>, <a class="last reference external" href="mailto:daniel@boostpro.com">daniel@boostpro.com</a></td></tr>
|
||||
<tr><th class="docinfo-name">Organization:</th>
|
||||
<td><a class="first last reference external" href="http://www.boost-consulting.com">Boost Consulting</a></td></tr>
|
||||
<td><a class="first last reference external" href="http://www.boostpro.com">BoostPro Computing</a></td></tr>
|
||||
<tr><th class="docinfo-name">Date:</th>
|
||||
<td>2005-07-17</td></tr>
|
||||
<tr><th class="docinfo-name">Copyright:</th>
|
||||
<td>Copyright David Abrahams, Daniel Wallin
|
||||
2005. Distributed under the Boost Software License,
|
||||
2005-2009. 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">http://www.boost.org/LICENSE_1_0.txt</a>)</td></tr>
|
||||
</tbody>
|
||||
@@ -907,8 +907,8 @@ namespace <em>namespace-name</em>
|
||||
return ##<em>tag-name</em>;
|
||||
}
|
||||
|
||||
typedef <em>implementation defined</em> _;
|
||||
typedef <em>implementation defined</em> _1;
|
||||
typedef <em>unspecified</em> _;
|
||||
typedef <em>unspecified</em> _1;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -926,8 +926,8 @@ namespace tag
|
||||
return ##<em>name</em>;
|
||||
}
|
||||
|
||||
typedef <em>implementation defined</em> _;
|
||||
typedef <em>implementation defined</em> _1;
|
||||
typedef <em>unspecified</em> _;
|
||||
typedef <em>unspecified</em> _1;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1128,7 +1128,7 @@ where it could make a difference.</td></tr>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<hr class="footer" />
|
||||
Generated on: 2008-06-26 21:51 UTC.
|
||||
Generated on: 2009-01-30 21:27 UTC.
|
||||
Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1902,10 +1902,12 @@ object.
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
using boost::bind;
|
||||
using boost::ref;
|
||||
|
||||
typename parameter::binding<
|
||||
ArgumentPack, tag::s3, std::string
|
||||
>::type s3 = args[_s3
|
||||
**|| boost::bind(std::plus<std::string>(), boost::ref(s1), boost::ref(s2))** ];
|
||||
>::type s3 = args[_s3 **|| bind(std::plus<std::string>(), ref(s1), ref(s2))** ];
|
||||
|
||||
.. @example.prepend('''
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <boost/parameter/aux_/default.hpp>
|
||||
#include <boost/parameter/aux_/parameter_requirements.hpp>
|
||||
#include <boost/parameter/aux_/yesno.hpp>
|
||||
#include <boost/parameter/aux_/is_maybe.hpp>
|
||||
#include <boost/parameter/aux_/maybe.hpp>
|
||||
#include <boost/parameter/config.hpp>
|
||||
|
||||
#include <boost/mpl/apply.hpp>
|
||||
@@ -22,11 +22,12 @@
|
||||
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/is_base_and_derived.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/facilities/intercept.hpp>
|
||||
|
||||
namespace boost { namespace parameter {
|
||||
namespace boost { namespace parameter {
|
||||
|
||||
// Forward declaration for aux::arg_list, below.
|
||||
template<class T> struct keyword;
|
||||
@@ -46,7 +47,7 @@ struct lambda_tag;
|
||||
// declarations to build member function overload sets that can
|
||||
// match against keywords.
|
||||
//
|
||||
|
||||
|
||||
// MPL sequence support
|
||||
struct arg_list_tag;
|
||||
|
||||
@@ -83,14 +84,14 @@ struct empty_arg_list
|
||||
template <class KW>
|
||||
static no_tag has_key(KW*);
|
||||
#endif
|
||||
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
|
||||
|| (BOOST_WORKAROUND(__GNUC__, < 3)) \
|
||||
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
|
||||
|
||||
// The overload set technique doesn't work with these older
|
||||
// compilers, so they need some explicit handholding.
|
||||
|
||||
|
||||
// A metafunction class that, given a keyword, returns the type
|
||||
// of the base sublist whose get() function can produce the
|
||||
// value for that key
|
||||
@@ -159,6 +160,11 @@ no_tag operator*(empty_arg_list, KW*);
|
||||
template <class KW, class T>
|
||||
struct tagged_argument;
|
||||
|
||||
template <class T>
|
||||
struct is_maybe
|
||||
: is_base_and_derived<maybe_base, T>
|
||||
{};
|
||||
|
||||
template <class T>
|
||||
struct get_reference
|
||||
{
|
||||
@@ -236,8 +242,8 @@ struct arg_list : Next
|
||||
// same keyword is used again
|
||||
static yes_tag has_key(key_type*);
|
||||
using Next::has_key;
|
||||
|
||||
# define BOOST_PARAMETER_CALL_HAS_KEY(next, key) next::has_key((key*)0)
|
||||
|
||||
# define BOOST_PARAMETER_CALL_HAS_KEY(next, key) next::has_key((key*)0)
|
||||
# endif
|
||||
|
||||
BOOST_MPL_ASSERT_MSG(
|
||||
@@ -252,7 +258,7 @@ struct arg_list : Next
|
||||
// specific arguments by name
|
||||
//
|
||||
|
||||
// Helpers that handle the case when TaggedArg is
|
||||
// Helpers that handle the case when TaggedArg is
|
||||
// empty<T>.
|
||||
template <class D>
|
||||
reference get_default(D const&, mpl::false_) const
|
||||
@@ -332,7 +338,7 @@ struct arg_list : Next
|
||||
template <class Default>
|
||||
reference get(default_<key_type,Default> const& d) const
|
||||
{
|
||||
return get_default(d, holds_maybe());
|
||||
return get_default(d, holds_maybe());
|
||||
}
|
||||
|
||||
template <class Default>
|
||||
@@ -340,7 +346,7 @@ struct arg_list : Next
|
||||
{
|
||||
return arg.value;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
reference operator[](keyword<key_type> const&) const
|
||||
@@ -395,7 +401,7 @@ struct arg_list : Next
|
||||
// Comma operator to compose argument list without using parameters<>.
|
||||
// Useful for argument lists with undetermined length.
|
||||
template <class KW, class T2>
|
||||
arg_list<tagged_argument<KW, T2>, self>
|
||||
arg_list<tagged_argument<KW, T2>, self>
|
||||
operator,(tagged_argument<KW,T2> x) const
|
||||
{
|
||||
return arg_list<tagged_argument<KW,T2>, self>(x, *this);
|
||||
@@ -409,7 +415,7 @@ struct arg_list : Next
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) // ETI workaround
|
||||
template <> struct arg_list<int,int> {};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// MPL sequence support
|
||||
template <class ArgumentPack>
|
||||
@@ -419,7 +425,7 @@ struct arg_list_iterator
|
||||
|
||||
// The incremented iterator
|
||||
typedef arg_list_iterator<typename ArgumentPack::tail_type> next;
|
||||
|
||||
|
||||
// dereferencing yields the key type
|
||||
typedef typename ArgumentPack::key_type type;
|
||||
};
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
// Copyright Daniel Wallin, David Abrahams 2010. Use, modification and
|
||||
// distribution is subject to 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)
|
||||
|
||||
#ifndef BOOST_PARAMETER_IS_MAYBE_050329_HPP
|
||||
#define BOOST_PARAMETER_IS_MAYBE_050329_HPP
|
||||
|
||||
#include <boost/type_traits/is_base_and_derived.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace parameter {
|
||||
namespace aux {
|
||||
|
||||
struct maybe_base {};
|
||||
|
||||
template <class T>
|
||||
struct is_maybe
|
||||
: is_base_and_derived<maybe_base, T>
|
||||
{};
|
||||
|
||||
} // namespace aux
|
||||
} // namespace parameter
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_PARAMETER_IS_MAYBE_050329_HPP
|
||||
@@ -16,7 +16,6 @@
|
||||
# include <boost/aligned_storage.hpp>
|
||||
# include <boost/type_traits/remove_cv.hpp>
|
||||
# include <boost/type_traits/add_const.hpp>
|
||||
# include <boost/parameter/aux_/is_maybe.hpp>
|
||||
|
||||
namespace boost { namespace parameter { namespace aux {
|
||||
|
||||
@@ -38,21 +37,23 @@ struct referent_storage
|
||||
>::type type;
|
||||
};
|
||||
|
||||
struct maybe_base {};
|
||||
|
||||
template <class T>
|
||||
struct maybe : maybe_base
|
||||
{
|
||||
typedef typename add_reference<
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
T const
|
||||
# else
|
||||
# else
|
||||
typename add_const<T>::type
|
||||
# endif
|
||||
# endif
|
||||
>::type reference;
|
||||
|
||||
|
||||
typedef typename remove_cv<
|
||||
BOOST_DEDUCED_TYPENAME remove_reference<reference>::type
|
||||
>::type non_cv_value;
|
||||
|
||||
|
||||
explicit maybe(T value_)
|
||||
: value(value_)
|
||||
, constructed(false)
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
||||
# include <boost/preprocessor/comparison/equal.hpp>
|
||||
# include <boost/preprocessor/control/if.hpp>
|
||||
# include <boost/preprocessor/control/iif.hpp>
|
||||
# include <boost/preprocessor/control/expr_if.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
# include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
@@ -27,7 +26,6 @@
|
||||
# include <boost/preprocessor/tuple/elem.hpp>
|
||||
# include <boost/preprocessor/tuple/eat.hpp>
|
||||
# include <boost/preprocessor/seq/fold_left.hpp>
|
||||
# include <boost/preprocessor/seq/push_back.hpp>
|
||||
# include <boost/preprocessor/seq/size.hpp>
|
||||
# include <boost/preprocessor/seq/enum.hpp>
|
||||
# include <boost/preprocessor/seq/push_back.hpp>
|
||||
|
||||
@@ -9,6 +9,8 @@ import python ;
|
||||
project boost/parameter
|
||||
: default-build <warnings>off
|
||||
;
|
||||
|
||||
build-project literate ;
|
||||
|
||||
test-suite "parameter"
|
||||
: [ run basics.cpp ]
|
||||
|
||||
33
test/literate/Jamfile.v2
Normal file
33
test/literate/Jamfile.v2
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
import testing ;
|
||||
|
||||
run extracting-parameter-types0.cpp ;
|
||||
run extracting-parameter-types1.cpp ;
|
||||
compile template-keywords0.cpp ;
|
||||
compile template-keywords1.cpp ;
|
||||
compile top-level0.cpp ;
|
||||
compile headers-and-namespaces0.cpp ;
|
||||
compile predicate-requirements0.cpp ;
|
||||
compile handling-out-parameters0.cpp ;
|
||||
compile writing-the-function0.cpp ;
|
||||
run building-argumentpacks0.cpp ;
|
||||
compile defining-the-keywords0.cpp ;
|
||||
compile defining-the-keywords1.cpp ;
|
||||
compile exercising-the-code-so-far0.cpp ;
|
||||
run lazy-default-computation0.cpp ;
|
||||
run lazy-default-computation1.cpp ;
|
||||
run namespaces0.cpp ;
|
||||
run namespaces1.cpp ;
|
||||
run namespaces2.cpp ;
|
||||
run namespaces3.cpp ;
|
||||
compile optional-parameters0.cpp ;
|
||||
compile static-member-functions0.cpp ;
|
||||
run parameter-enabled-constructors0.cpp ;
|
||||
compile required-parameters0.cpp ;
|
||||
compile class-template-skeleton0.cpp ;
|
||||
compile deduced-template-parameters0.cpp ;
|
||||
compile deduced-parameters0.cpp ;
|
||||
compile default-expression-evaluation0.cpp ;
|
||||
compile parameter-enabled-member-functions0.cpp ;
|
||||
compile parameter-enabled-member-functions1.cpp ;
|
||||
run fine-grained-name-control0.cpp ;
|
||||
6
test/literate/README
Normal file
6
test/literate/README
Normal file
@@ -0,0 +1,6 @@
|
||||
These tests were extracted from the Boost.Parameter documentation
|
||||
with:
|
||||
|
||||
python ../../../../tools/litre/tool.py \
|
||||
../../../../libs/parameter/doc/index.rst \
|
||||
--dump_dir=.
|
||||
53
test/literate/building-argumentpacks0.cpp
Normal file
53
test/literate/building-argumentpacks0.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
#line 1711 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
#line 1700 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
template <class ArgumentPack>
|
||||
int print_index(ArgumentPack const& args)
|
||||
{
|
||||
std::cout << "index = " << args[_index] << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int x = print_index(_index = 3); // prints "index = 3"
|
||||
|
||||
#line 1719 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
|
||||
template <class ArgumentPack>
|
||||
int print_name_and_index(ArgumentPack const& args)
|
||||
{
|
||||
std::cout << "name = " << args[_name] << "; ";
|
||||
return print_index(args);
|
||||
}
|
||||
|
||||
int y = print_name_and_index((_index = 3, _name = "jones"));
|
||||
|
||||
|
||||
#line 1754 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace parameter = boost::parameter;
|
||||
using parameter::required;
|
||||
using parameter::optional;
|
||||
using boost::is_convertible;
|
||||
using boost::mpl::_;
|
||||
#line 1740 "../../../../libs/parameter/doc/index.rst"
|
||||
parameter::parameters<
|
||||
required<tag::name, is_convertible<_,char const*> >
|
||||
, optional<tag::index, is_convertible<_,int> >
|
||||
> spec;
|
||||
|
||||
char const sam[] = "sam";
|
||||
int twelve = 12;
|
||||
|
||||
int z0 = print_name_and_index( spec(sam, twelve) );
|
||||
|
||||
int z1 = print_name_and_index(
|
||||
spec(_index=12, _name="sam")
|
||||
);
|
||||
#line 1761 "../../../../libs/parameter/doc/index.rst"
|
||||
int main()
|
||||
{}
|
||||
|
||||
18
test/literate/class-template-skeleton0.cpp
Normal file
18
test/literate/class-template-skeleton0.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
#line 1354 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#line 1340 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace boost { namespace python {
|
||||
|
||||
template <
|
||||
class A0
|
||||
, class A1 = parameter::void_
|
||||
, class A2 = parameter::void_
|
||||
, class A3 = parameter::void_
|
||||
>
|
||||
struct class_
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
80
test/literate/deduced-parameters0.cpp
Normal file
80
test/literate/deduced-parameters0.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
|
||||
#line 1029 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
BOOST_PARAMETER_NAME(func)
|
||||
BOOST_PARAMETER_NAME(docstring)
|
||||
BOOST_PARAMETER_NAME(keywords)
|
||||
BOOST_PARAMETER_NAME(policies)
|
||||
|
||||
struct default_call_policies
|
||||
{};
|
||||
|
||||
struct no_keywords
|
||||
{};
|
||||
|
||||
struct keywords
|
||||
{};
|
||||
|
||||
template <class T>
|
||||
struct is_keyword_expression
|
||||
: boost::mpl::false_
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct is_keyword_expression<keywords>
|
||||
: boost::mpl::true_
|
||||
{};
|
||||
|
||||
default_call_policies some_policies;
|
||||
|
||||
void f()
|
||||
{}
|
||||
#line 996 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace mpl = boost::mpl;
|
||||
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
(void), def, tag,
|
||||
|
||||
(required (name,(char const*)) (func,*) ) // nondeduced
|
||||
|
||||
(deduced
|
||||
(optional
|
||||
(docstring, (char const*), "")
|
||||
|
||||
(keywords
|
||||
, *(is_keyword_expression<mpl::_>) // see 5
|
||||
, no_keywords())
|
||||
|
||||
(policies
|
||||
, *(mpl::not_<
|
||||
mpl::or_<
|
||||
boost::is_convertible<mpl::_, char const*>
|
||||
, is_keyword_expression<mpl::_> // see 5
|
||||
>
|
||||
>)
|
||||
, default_call_policies()
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#line 1078 "../../../../libs/parameter/doc/index.rst"
|
||||
int main()
|
||||
{
|
||||
#line 1075 "../../../../libs/parameter/doc/index.rst"
|
||||
def("f", &f, some_policies, "Documentation for f");
|
||||
def("f", &f, "Documentation for f", some_policies);
|
||||
|
||||
#line 1088 "../../../../libs/parameter/doc/index.rst"
|
||||
def(
|
||||
"f", &f
|
||||
, _policies = some_policies, "Documentation for f");
|
||||
#line 1091 "../../../../libs/parameter/doc/index.rst"
|
||||
}
|
||||
|
||||
111
test/literate/deduced-template-parameters0.cpp
Normal file
111
test/literate/deduced-template-parameters0.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
|
||||
#line 1524 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <memory>
|
||||
|
||||
using namespace boost::parameter;
|
||||
using boost::mpl::_;
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type)
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list)
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type)
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable)
|
||||
|
||||
}}
|
||||
#line 1513 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace detail { struct bases_base {}; }
|
||||
|
||||
template <class A0 = void, class A1 = void, class A2 = void >
|
||||
struct bases : detail::bases_base
|
||||
{};
|
||||
|
||||
}}
|
||||
|
||||
|
||||
#line 1567 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
namespace boost { namespace python {
|
||||
#line 1545 "../../../../libs/parameter/doc/index.rst"
|
||||
typedef parameter::parameters<
|
||||
required<tag::class_type, is_class<_> >
|
||||
|
||||
, parameter::optional<
|
||||
deduced<tag::base_list>
|
||||
, is_base_and_derived<detail::bases_base,_>
|
||||
>
|
||||
|
||||
, parameter::optional<
|
||||
deduced<tag::held_type>
|
||||
, mpl::not_<
|
||||
mpl::or_<
|
||||
is_base_and_derived<detail::bases_base,_>
|
||||
, is_same<noncopyable,_>
|
||||
>
|
||||
>
|
||||
>
|
||||
|
||||
, parameter::optional<deduced<tag::copyable>, is_same<noncopyable,_> >
|
||||
|
||||
> class_signature;
|
||||
#line 1571 "../../../../libs/parameter/doc/index.rst"
|
||||
template <
|
||||
class A0
|
||||
, class A1 = parameter::void_
|
||||
, class A2 = parameter::void_
|
||||
, class A3 = parameter::void_
|
||||
>
|
||||
struct class_
|
||||
{
|
||||
// Create ArgumentPack
|
||||
typedef typename
|
||||
class_signature::bind<A0,A1,A2,A3>::type
|
||||
args;
|
||||
|
||||
// Extract first logical parameter.
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::class_type>::type class_type;
|
||||
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::base_list, bases<> >::type base_list;
|
||||
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::held_type, class_type>::type held_type;
|
||||
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::copyable, void>::type copyable;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
|
||||
|
||||
#line 1611 "../../../../libs/parameter/doc/index.rst"
|
||||
struct B {};
|
||||
struct D {};
|
||||
|
||||
using boost::python::bases;
|
||||
#line 1607 "../../../../libs/parameter/doc/index.rst"
|
||||
typedef boost::python::class_<B, boost::noncopyable> c1;
|
||||
|
||||
typedef boost::python::class_<D, std::auto_ptr<D>, bases<B> > c2;
|
||||
#line 1617 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_MPL_ASSERT((boost::is_same<c1::class_type, B>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<c1::base_list, bases<> >));
|
||||
BOOST_MPL_ASSERT((boost::is_same<c1::held_type, B>));
|
||||
BOOST_MPL_ASSERT((
|
||||
boost::is_same<c1::copyable, boost::noncopyable>
|
||||
));
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<c2::class_type, D>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<c2::base_list, bases<B> >));
|
||||
BOOST_MPL_ASSERT((
|
||||
boost::is_same<c2::held_type, std::auto_ptr<D> >
|
||||
));
|
||||
BOOST_MPL_ASSERT((boost::is_same<c2::copyable, void>));
|
||||
|
||||
41
test/literate/default-expression-evaluation0.cpp
Normal file
41
test/literate/default-expression-evaluation0.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#line 730 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
|
||||
BOOST_PARAMETER_NAME(graph)
|
||||
BOOST_PARAMETER_NAME(visitor)
|
||||
BOOST_PARAMETER_NAME(root_vertex)
|
||||
BOOST_PARAMETER_NAME(index_map)
|
||||
BOOST_PARAMETER_NAME(color_map)
|
||||
#line 702 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/graph/depth_first_search.hpp> // for dfs_visitor
|
||||
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
(void), depth_first_search, tag
|
||||
|
||||
, (required
|
||||
(graph, *)
|
||||
(visitor, *)
|
||||
(root_vertex, *)
|
||||
(index_map, *)
|
||||
(color_map, *)
|
||||
)
|
||||
|
||||
)
|
||||
{
|
||||
std::cout << "graph=" << graph << std::endl;
|
||||
std::cout << "visitor=" << visitor << std::endl;
|
||||
std::cout << "root_vertex=" << root_vertex << std::endl;
|
||||
std::cout << "index_map=" << index_map << std::endl;
|
||||
std::cout << "color_map=" << color_map << std::endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
depth_first_search(1, 2, 3, 4, 5);
|
||||
|
||||
depth_first_search(
|
||||
"1", '2', _color_map = '5',
|
||||
_index_map = "4", _root_vertex = "3");
|
||||
}
|
||||
11
test/literate/defining-the-keywords0.cpp
Normal file
11
test/literate/defining-the-keywords0.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#line 397 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter/name.hpp>
|
||||
|
||||
namespace graphs
|
||||
{
|
||||
BOOST_PARAMETER_NAME(graph) // Note: no semicolon
|
||||
BOOST_PARAMETER_NAME(visitor)
|
||||
BOOST_PARAMETER_NAME(root_vertex)
|
||||
BOOST_PARAMETER_NAME(index_map)
|
||||
BOOST_PARAMETER_NAME(color_map)
|
||||
}
|
||||
15
test/literate/defining-the-keywords1.cpp
Normal file
15
test/literate/defining-the-keywords1.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
#line 424 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#line 413 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace graphs
|
||||
{
|
||||
namespace tag { struct graph; } // keyword tag type
|
||||
|
||||
namespace // unnamed
|
||||
{
|
||||
// A reference to the keyword object
|
||||
boost::parameter::keyword<tag::graph>& _graph
|
||||
= boost::parameter::keyword<tag::graph>::get();
|
||||
}
|
||||
}
|
||||
101
test/literate/exercising-the-code-so-far0.cpp
Normal file
101
test/literate/exercising-the-code-so-far0.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
|
||||
#line 1382 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <boost/mpl/is_sequence.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <memory>
|
||||
|
||||
using namespace boost::parameter;
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type)
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list)
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type)
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable)
|
||||
|
||||
template <class B = int>
|
||||
struct bases
|
||||
{};
|
||||
|
||||
}}
|
||||
#line 1369 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace boost { namespace python {
|
||||
|
||||
using boost::mpl::_;
|
||||
|
||||
typedef parameter::parameters<
|
||||
required<tag::class_type, boost::is_class<_> >
|
||||
, parameter::optional<tag::base_list, mpl::is_sequence<_> >
|
||||
, parameter::optional<tag::held_type>
|
||||
, parameter::optional<tag::copyable>
|
||||
> class_signature;
|
||||
|
||||
}}
|
||||
|
||||
#line 1421 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace boost { namespace python {
|
||||
|
||||
template <
|
||||
class A0
|
||||
, class A1 = parameter::void_
|
||||
, class A2 = parameter::void_
|
||||
, class A3 = parameter::void_
|
||||
>
|
||||
struct class_
|
||||
{
|
||||
// Create ArgumentPack
|
||||
typedef typename
|
||||
class_signature::bind<A0,A1,A2,A3>::type
|
||||
args;
|
||||
|
||||
// Extract first logical parameter.
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::class_type>::type class_type;
|
||||
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::base_list, bases<> >::type base_list;
|
||||
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::held_type, class_type>::type held_type;
|
||||
|
||||
typedef typename parameter::value_type<
|
||||
args, tag::copyable, void>::type copyable;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
|
||||
#line 1 "None"
|
||||
using boost::python::class_type;
|
||||
using boost::python::copyable;
|
||||
using boost::python::held_type;
|
||||
using boost::python::base_list;
|
||||
using boost::python::bases;
|
||||
|
||||
struct B {};
|
||||
struct D {};
|
||||
#line 1462 "../../../../libs/parameter/doc/index.rst"
|
||||
typedef boost::python::class_<
|
||||
class_type<B>, copyable<boost::noncopyable>
|
||||
> c1;
|
||||
|
||||
typedef boost::python::class_<
|
||||
D, held_type<std::auto_ptr<D> >, base_list<bases<B> >
|
||||
> c2;
|
||||
|
||||
#line 1482 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_MPL_ASSERT((boost::is_same<c1::class_type, B>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<c1::base_list, bases<> >));
|
||||
BOOST_MPL_ASSERT((boost::is_same<c1::held_type, B>));
|
||||
BOOST_MPL_ASSERT((
|
||||
boost::is_same<c1::copyable, boost::noncopyable>
|
||||
));
|
||||
|
||||
BOOST_MPL_ASSERT((boost::is_same<c2::class_type, D>));
|
||||
BOOST_MPL_ASSERT((boost::is_same<c2::base_list, bases<B> >));
|
||||
BOOST_MPL_ASSERT((
|
||||
boost::is_same<c2::held_type, std::auto_ptr<D> >
|
||||
));
|
||||
BOOST_MPL_ASSERT((boost::is_same<c2::copyable, void>));
|
||||
31
test/literate/extracting-parameter-types0.cpp
Normal file
31
test/literate/extracting-parameter-types0.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
#line 1797 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <cassert>
|
||||
#line 1780 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
template <class Name, class Index>
|
||||
int deduce_arg_types_impl(Name& name, Index& index)
|
||||
{
|
||||
Name& n2 = name; // we know the types
|
||||
Index& i2 = index;
|
||||
return index;
|
||||
}
|
||||
|
||||
template <class ArgumentPack>
|
||||
int deduce_arg_types(ArgumentPack const& args)
|
||||
{
|
||||
return deduce_arg_types_impl(args[_name], args[_index|42]);
|
||||
}
|
||||
#line 1801 "../../../../libs/parameter/doc/index.rst"
|
||||
int a1 = deduce_arg_types((_name = "foo"));
|
||||
int a2 = deduce_arg_types((_name = "foo", _index = 3));
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(a1 == 42);
|
||||
assert(a2 == 3);
|
||||
}
|
||||
|
||||
24
test/literate/extracting-parameter-types1.cpp
Normal file
24
test/literate/extracting-parameter-types1.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
#line 1830 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <cassert>
|
||||
|
||||
namespace parameter = boost::parameter;
|
||||
#line 1819 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
template <class ArgumentPack>
|
||||
typename parameter::value_type<ArgumentPack, tag::index, int>::type
|
||||
twice_index(ArgumentPack const& args)
|
||||
{
|
||||
return 2 * args[_index|42];
|
||||
}
|
||||
|
||||
int six = twice_index(_index = 3);
|
||||
#line 1838 "../../../../libs/parameter/doc/index.rst"
|
||||
int main()
|
||||
{
|
||||
assert(six == 6);
|
||||
}
|
||||
|
||||
18
test/literate/fine-grained-name-control0.cpp
Normal file
18
test/literate/fine-grained-name-control0.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
#line 1670 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#line 1660 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME((pass_foo, keywords) foo)
|
||||
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
(int), f,
|
||||
keywords, (required (foo, *)))
|
||||
{
|
||||
return foo + 1;
|
||||
}
|
||||
|
||||
int x = f(pass_foo = 41);
|
||||
#line 1671 "../../../../libs/parameter/doc/index.rst"
|
||||
int main()
|
||||
{}
|
||||
|
||||
33
test/literate/handling-out-parameters0.cpp
Normal file
33
test/literate/handling-out-parameters0.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
#line 620 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
int vertex_index = 0;
|
||||
|
||||
template <class T = int>
|
||||
struct dfs_visitor
|
||||
{};
|
||||
}
|
||||
|
||||
BOOST_PARAMETER_NAME(graph)
|
||||
|
||||
BOOST_PARAMETER_NAME(visitor)
|
||||
BOOST_PARAMETER_NAME(root_vertex)
|
||||
BOOST_PARAMETER_NAME(index_map)
|
||||
BOOST_PARAMETER_NAME(color_map)
|
||||
|
||||
BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
(required (graph, *))
|
||||
#line 612 "../../../../libs/parameter/doc/index.rst"
|
||||
(optional
|
||||
(visitor, *, boost::dfs_visitor<>())
|
||||
(root_vertex, *, *vertices(graph).first)
|
||||
(index_map, *, get(boost::vertex_index,graph))
|
||||
(in_out(color_map), *,
|
||||
default_color_map(num_vertices(graph), index_map) )
|
||||
)
|
||||
#line 642 "../../../../libs/parameter/doc/index.rst"
|
||||
) {}
|
||||
|
||||
5
test/literate/headers-and-namespaces0.cpp
Normal file
5
test/literate/headers-and-namespaces0.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#line 274 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter/keyword.hpp>
|
||||
#line 283 "../../../../libs/parameter/doc/index.rst"
|
||||
using boost::parameter::keyword;
|
||||
|
||||
27
test/literate/lazy-default-computation0.cpp
Normal file
27
test/literate/lazy-default-computation0.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
#line 1878 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace parameter = boost::parameter;
|
||||
#line 1861 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(s1)
|
||||
BOOST_PARAMETER_NAME(s2)
|
||||
BOOST_PARAMETER_NAME(s3)
|
||||
|
||||
template <class ArgumentPack>
|
||||
std::string f(ArgumentPack const& args)
|
||||
{
|
||||
std::string const& s1 = args[_s1];
|
||||
std::string const& s2 = args[_s2];
|
||||
typename parameter::binding<
|
||||
ArgumentPack,tag::s3,std::string
|
||||
>::type s3 = args[_s3|(s1+s2)]; // always constructs s1+s2
|
||||
return s3;
|
||||
}
|
||||
|
||||
std::string x = f((_s1="hello,", _s2=" world", _s3="hi world"));
|
||||
#line 1884 "../../../../libs/parameter/doc/index.rst"
|
||||
int main()
|
||||
{}
|
||||
|
||||
35
test/literate/lazy-default-computation1.cpp
Normal file
35
test/literate/lazy-default-computation1.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
#line 1912 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/parameter.hpp>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
namespace parameter = boost::parameter;
|
||||
|
||||
BOOST_PARAMETER_NAME(s1)
|
||||
BOOST_PARAMETER_NAME(s2)
|
||||
BOOST_PARAMETER_NAME(s3)
|
||||
|
||||
template <class ArgumentPack>
|
||||
std::string f(ArgumentPack const& args)
|
||||
{
|
||||
std::string const& s1 = args[_s1];
|
||||
std::string const& s2 = args[_s2];
|
||||
#line 1905 "../../../../libs/parameter/doc/index.rst"
|
||||
using boost::bind;
|
||||
using boost::ref;
|
||||
|
||||
typename parameter::binding<
|
||||
ArgumentPack, tag::s3, std::string
|
||||
>::type s3 = args[_s3 || bind(std::plus<std::string>(), ref(s1), ref(s2)) ];
|
||||
#line 1931 "../../../../libs/parameter/doc/index.rst"
|
||||
return s3;
|
||||
}
|
||||
|
||||
std::string x = f((_s1="hello,", _s2=" world", _s3="hi world"));
|
||||
|
||||
int main()
|
||||
{}
|
||||
|
||||
25
test/literate/namespaces0.cpp
Normal file
25
test/literate/namespaces0.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
#line 2051 "../../../../libs/parameter/doc/index.rst"
|
||||
#line 2054 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
#line 2040 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace lib
|
||||
{
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
(int), f, tag,
|
||||
(optional (name,*,"bob")(index,(int),1))
|
||||
)
|
||||
{
|
||||
std::cout << name << ":" << index << std::endl;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
#line 2067 "../../../../libs/parameter/doc/index.rst"
|
||||
int x = lib::f(lib::_name = "jill", lib::_index = 1);
|
||||
#line 2071 "../../../../libs/parameter/doc/index.rst"
|
||||
int main() {}
|
||||
|
||||
28
test/literate/namespaces1.cpp
Normal file
28
test/literate/namespaces1.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
#line 2069 "../../../../libs/parameter/doc/index.rst"
|
||||
#line 2054 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
#line 2040 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace lib
|
||||
{
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
(int), f, tag,
|
||||
(optional (name,*,"bob")(index,(int),1))
|
||||
)
|
||||
{
|
||||
std::cout << name << ":" << index << std::endl;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
#line 2080 "../../../../libs/parameter/doc/index.rst"
|
||||
using lib::_name;
|
||||
using lib::_index;
|
||||
|
||||
int x = lib::f(_name = "jill", _index = 1);
|
||||
#line 2089 "../../../../libs/parameter/doc/index.rst"
|
||||
int main() {}
|
||||
|
||||
26
test/literate/namespaces2.cpp
Normal file
26
test/literate/namespaces2.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
#line 2083 "../../../../libs/parameter/doc/index.rst"
|
||||
#line 2054 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
#line 2040 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace lib
|
||||
{
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
(int), f, tag,
|
||||
(optional (name,*,"bob")(index,(int),1))
|
||||
)
|
||||
{
|
||||
std::cout << name << ":" << index << std::endl;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
#line 2097 "../../../../libs/parameter/doc/index.rst"
|
||||
using namespace lib;
|
||||
int x = f(_name = "jill", _index = 3);
|
||||
#line 2103 "../../../../libs/parameter/doc/index.rst"
|
||||
int main() {}
|
||||
|
||||
29
test/literate/namespaces3.cpp
Normal file
29
test/literate/namespaces3.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
#line 2130 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
#line 2112 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace lib
|
||||
{
|
||||
namespace keywords
|
||||
{
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
}
|
||||
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
(int), f, keywords::tag,
|
||||
(optional (name,*,"bob")(index,(int),1))
|
||||
)
|
||||
{
|
||||
std::cout << name << ":" << index << std::endl;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
#line 2139 "../../../../libs/parameter/doc/index.rst"
|
||||
using namespace lib::keywords;
|
||||
int y = lib::f(_name = "bob", _index = 2);
|
||||
#line 2141 "../../../../libs/parameter/doc/index.rst"
|
||||
int main() {}
|
||||
|
||||
31
test/literate/optional-parameters0.cpp
Normal file
31
test/literate/optional-parameters0.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
#line 571 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
int vertex_index = 0;
|
||||
|
||||
template <class T = int>
|
||||
struct dfs_visitor
|
||||
{};
|
||||
}
|
||||
|
||||
BOOST_PARAMETER_NAME(graph)
|
||||
BOOST_PARAMETER_NAME(visitor)
|
||||
BOOST_PARAMETER_NAME(root_vertex)
|
||||
BOOST_PARAMETER_NAME(index_map)
|
||||
BOOST_PARAMETER_NAME(color_map)
|
||||
|
||||
BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
(required (graph, *))
|
||||
#line 563 "../../../../libs/parameter/doc/index.rst"
|
||||
(optional (visitor, *, boost::dfs_visitor<>())
|
||||
(root_vertex, *, *vertices(graph).first)
|
||||
(index_map, *, get(boost::vertex_index,graph))
|
||||
(in_out(color_map), *,
|
||||
default_color_map(num_vertices(graph), index_map) )
|
||||
)
|
||||
#line 592 "../../../../libs/parameter/doc/index.rst"
|
||||
) {}
|
||||
|
||||
37
test/literate/parameter-enabled-constructors0.cpp
Normal file
37
test/literate/parameter-enabled-constructors0.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
#line 1215 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
#line 1201 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(name)
|
||||
BOOST_PARAMETER_NAME(index)
|
||||
|
||||
struct myclass_impl
|
||||
{
|
||||
template <class ArgumentPack>
|
||||
myclass_impl(ArgumentPack const& args)
|
||||
{
|
||||
std::cout << "name = " << args[_name]
|
||||
<< "; index = " << args[_index | 42]
|
||||
<< std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
#line 1228 "../../../../libs/parameter/doc/index.rst"
|
||||
struct myclass : myclass_impl
|
||||
{
|
||||
BOOST_PARAMETER_CONSTRUCTOR(
|
||||
myclass, (myclass_impl), tag
|
||||
, (required (name,*)) (optional (index,*))) // no semicolon
|
||||
};
|
||||
|
||||
|
||||
#line 1242 "../../../../libs/parameter/doc/index.rst"
|
||||
int main() {
|
||||
#line 1239 "../../../../libs/parameter/doc/index.rst"
|
||||
myclass x("bob", 3); // positional
|
||||
myclass y(_index = 12, _name = "sally"); // named
|
||||
myclass z("june"); // positional/defaulted
|
||||
#line 1242 "../../../../libs/parameter/doc/index.rst"
|
||||
}
|
||||
|
||||
17
test/literate/parameter-enabled-member-functions0.cpp
Normal file
17
test/literate/parameter-enabled-member-functions0.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
#line 1121 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
using namespace boost::parameter;
|
||||
#line 1109 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(arg1)
|
||||
BOOST_PARAMETER_NAME(arg2)
|
||||
|
||||
struct callable2
|
||||
{
|
||||
BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
|
||||
(void), call, tag, (required (arg1,(int))(arg2,(int))))
|
||||
{
|
||||
std::cout << arg1 << ", " << arg2 << std::endl;
|
||||
}
|
||||
};
|
||||
18
test/literate/parameter-enabled-member-functions1.cpp
Normal file
18
test/literate/parameter-enabled-member-functions1.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
#line 1144 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
BOOST_PARAMETER_NAME(arg1)
|
||||
BOOST_PARAMETER_NAME(arg2)
|
||||
using namespace boost::parameter;
|
||||
#line 1133 "../../../../libs/parameter/doc/index.rst"
|
||||
struct callable2
|
||||
{
|
||||
BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
|
||||
(void), call, tag, (required (arg1,(int))(arg2,(int))))
|
||||
{
|
||||
call_impl(arg1,arg2);
|
||||
}
|
||||
private:
|
||||
void call_impl(int, int); // implemented elsewhere.
|
||||
};
|
||||
84
test/literate/predicate-requirements0.cpp
Normal file
84
test/literate/predicate-requirements0.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
#line 903 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
BOOST_PARAMETER_NAME((_graph, graphs) graph)
|
||||
BOOST_PARAMETER_NAME((_visitor, graphs) visitor)
|
||||
BOOST_PARAMETER_NAME((_root_vertex, graphs) root_vertex)
|
||||
BOOST_PARAMETER_NAME((_index_map, graphs) index_map)
|
||||
BOOST_PARAMETER_NAME((_color_map, graphs) color_map)
|
||||
|
||||
using boost::mpl::_;
|
||||
|
||||
namespace boost
|
||||
{
|
||||
struct incidence_graph_tag {};
|
||||
struct vertex_list_graph_tag {};
|
||||
|
||||
int vertex_index = 0;
|
||||
|
||||
template <class T>
|
||||
struct graph_traits
|
||||
{
|
||||
typedef int traversal_category;
|
||||
typedef int vertex_descriptor;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct property_traits
|
||||
{
|
||||
typedef int value_type;
|
||||
typedef int key_type;
|
||||
};
|
||||
|
||||
template <class T = int>
|
||||
struct dfs_visitor
|
||||
{};
|
||||
}
|
||||
#line 859 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
(void), depth_first_search, graphs
|
||||
|
||||
, (required
|
||||
(graph
|
||||
, *(boost::mpl::and_<
|
||||
boost::is_convertible<
|
||||
boost::graph_traits<_>::traversal_category
|
||||
, boost::incidence_graph_tag
|
||||
>
|
||||
, boost::is_convertible<
|
||||
boost::graph_traits<_>::traversal_category
|
||||
, boost::vertex_list_graph_tag
|
||||
>
|
||||
>) ))
|
||||
|
||||
(optional
|
||||
(visitor, *, boost::dfs_visitor<>()) // not checkable
|
||||
|
||||
(root_vertex
|
||||
, (typename boost::graph_traits<graphs::graph::_>::vertex_descriptor)
|
||||
, *vertices(graph).first)
|
||||
|
||||
(index_map
|
||||
, *(boost::mpl::and_<
|
||||
boost::is_integral<
|
||||
boost::property_traits<_>::value_type
|
||||
>
|
||||
, boost::is_same<
|
||||
typename boost::graph_traits<graphs::graph::_>::vertex_descriptor
|
||||
, boost::property_traits<_>::key_type
|
||||
>
|
||||
>)
|
||||
, get(boost::vertex_index,graph))
|
||||
|
||||
(in_out(color_map)
|
||||
, *(boost::is_same<
|
||||
typename boost::graph_traits<graphs::graph::_>::vertex_descriptor
|
||||
, boost::property_traits<_>::key_type
|
||||
>)
|
||||
, default_color_map(num_vertices(graph), index_map) )
|
||||
)
|
||||
)
|
||||
#line 940 "../../../../libs/parameter/doc/index.rst"
|
||||
{}
|
||||
|
||||
12
test/literate/required-parameters0.cpp
Normal file
12
test/literate/required-parameters0.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
#line 540 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
BOOST_PARAMETER_NAME(graph)
|
||||
|
||||
BOOST_PARAMETER_FUNCTION((void), f, tag,
|
||||
#line 531 "../../../../libs/parameter/doc/index.rst"
|
||||
(required (graph, *) )
|
||||
#line 547 "../../../../libs/parameter/doc/index.rst"
|
||||
) {}
|
||||
|
||||
16
test/literate/static-member-functions0.cpp
Normal file
16
test/literate/static-member-functions0.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
#line 1173 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#include <iostream>
|
||||
using namespace boost::parameter;
|
||||
#line 1162 "../../../../libs/parameter/doc/index.rst"
|
||||
BOOST_PARAMETER_NAME(arg1)
|
||||
|
||||
struct somebody
|
||||
{
|
||||
BOOST_PARAMETER_MEMBER_FUNCTION(
|
||||
(void), static f, tag, (optional (arg1,(int),0)))
|
||||
{
|
||||
std::cout << arg1 << std::endl;
|
||||
}
|
||||
};
|
||||
12
test/literate/template-keywords0.cpp
Normal file
12
test/literate/template-keywords0.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
#line 1304 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#line 1296 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace boost { namespace python {
|
||||
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type)
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list)
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type)
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable)
|
||||
|
||||
}}
|
||||
13
test/literate/template-keywords1.cpp
Normal file
13
test/literate/template-keywords1.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
#line 1320 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
#line 1311 "../../../../libs/parameter/doc/index.rst"
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace tag { struct class_type; } // keyword tag type
|
||||
template <class T>
|
||||
struct class_type
|
||||
: parameter::template_keyword<tag::class_type,T>
|
||||
{};
|
||||
|
||||
}}
|
||||
40
test/literate/top-level0.cpp
Normal file
40
test/literate/top-level0.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
#line 35 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter.hpp>
|
||||
|
||||
namespace test
|
||||
{
|
||||
BOOST_PARAMETER_NAME(title)
|
||||
BOOST_PARAMETER_NAME(width)
|
||||
BOOST_PARAMETER_NAME(titlebar)
|
||||
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
(int), new_window, tag, (required (title,*)(width,*)(titlebar,*)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(deleter)
|
||||
BOOST_PARAMETER_TEMPLATE_KEYWORD(copy_policy)
|
||||
|
||||
template <class T> struct Deallocate {};
|
||||
struct DeepCopy {};
|
||||
|
||||
namespace parameter = boost::parameter;
|
||||
|
||||
struct Foo {};
|
||||
template <class T, class A0, class A1>
|
||||
struct smart_ptr
|
||||
{
|
||||
smart_ptr(Foo*);
|
||||
};
|
||||
}
|
||||
using namespace test;
|
||||
int x =
|
||||
#line 19
|
||||
new_window("alert", _width=10, _titlebar=false);
|
||||
|
||||
smart_ptr<
|
||||
Foo
|
||||
, deleter<Deallocate<Foo> >
|
||||
, copy_policy<DeepCopy> > p(new Foo);
|
||||
45
test/literate/writing-the-function0.cpp
Normal file
45
test/literate/writing-the-function0.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
#line 472 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter/name.hpp>
|
||||
|
||||
BOOST_PARAMETER_NAME(graph)
|
||||
BOOST_PARAMETER_NAME(visitor)
|
||||
BOOST_PARAMETER_NAME(root_vertex)
|
||||
BOOST_PARAMETER_NAME(index_map)
|
||||
BOOST_PARAMETER_NAME(color_map)
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <class T = int>
|
||||
struct dfs_visitor
|
||||
{};
|
||||
|
||||
int vertex_index = 0;
|
||||
|
||||
}
|
||||
#line 446 "../../../../libs/parameter/doc/index.rst"
|
||||
#include <boost/parameter/preprocessor.hpp>
|
||||
|
||||
namespace graphs
|
||||
{
|
||||
BOOST_PARAMETER_FUNCTION(
|
||||
(void), // 1. parenthesized return type
|
||||
depth_first_search, // 2. name of the function template
|
||||
|
||||
tag, // 3. namespace of tag types
|
||||
|
||||
(required (graph, *) ) // 4. one required parameter, and
|
||||
|
||||
(optional // four optional parameters, with defaults
|
||||
(visitor, *, boost::dfs_visitor<>())
|
||||
(root_vertex, *, *vertices(graph).first)
|
||||
(index_map, *, get(boost::vertex_index,graph))
|
||||
(in_out(color_map), *,
|
||||
default_color_map(num_vertices(graph), index_map) )
|
||||
)
|
||||
)
|
||||
{
|
||||
// ... body of function goes here...
|
||||
// use graph, visitor, index_map, and color_map
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user