Skip to content

Commit

Permalink
Merge pull request #61 from CromwellEnage/feature_compose_max_arity
Browse files Browse the repository at this point in the history
 Add configuration macro BOOST_PARAMETER_COMPOSE_MAX_ARITY
  • Loading branch information
eldiener committed Jan 16, 2019
2 parents 1fde7ae + e5337e2 commit b531b64
Show file tree
Hide file tree
Showing 14 changed files with 296 additions and 95 deletions.
81 changes: 75 additions & 6 deletions doc/html/reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,15 @@ <h1 class="title">The Boost Parameter Library Reference Documentation</h1>
<li><a class="reference internal" href="#boost-parameter-max-arity"
id="id86">8.6&nbsp;&nbsp;&nbsp;<tt class="docutils literal"
>BOOST_PARAMETER_MAX_ARITY</tt></a></li>
<li><a class="reference internal" href="#boost-parameter-compose-max-arity"
id="id87">8.7&nbsp;&nbsp;&nbsp;<tt class="docutils literal"
>BOOST_PARAMETER_COMPOSE_MAX_ARITY</tt></a></li>
<li><a class="reference internal"
href="#boost-parameter-exponential-overload-threshold-arity"
id="id88">8.7&nbsp;&nbsp;&nbsp;<tt class="docutils literal"
id="id88">8.8&nbsp;&nbsp;&nbsp;<tt class="docutils literal"
>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY</tt></a></li>
<li><a class="reference internal" href="#outside-of-this-library"
id="id89">8.8&nbsp;&nbsp;&nbsp;...Outside Of This Library</a></li>
id="id89">8.9&nbsp;&nbsp;&nbsp;...Outside Of This Library</a></li>
</ul>
</li>
<li><a class="reference internal" href="#tutorial"
Expand Down Expand Up @@ -1890,8 +1893,8 @@ <h2><a class="toc-backref" href="#id54">6.1&nbsp;&nbsp;&nbsp;<tt
the resulting <a class="reference internal" href="#argumentpack"><span
class="concept">ArgumentPack</span></a>, while the <tt
class="docutils literal">compose()</tt> function cannot take in more than <a
class="reference internal" href="#boost-parameter-max-arity"><tt
class="docutils literal">BOOST_PARAMETER_MAX_ARITY</tt></a> arguments
class="reference internal" href="#boost-parameter-compose-max-arity"><tt
class="docutils literal">BOOST_PARAMETER_COMPOSE_MAX_ARITY</tt></a> arguments
for compilers that do not support perfect forwarding.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
Expand Down Expand Up @@ -9382,11 +9385,77 @@ <h2><a class="toc-backref" href="#id86">8.6&nbsp;&nbsp;&nbsp;<tt
<th class="field-name">Minimum Value:</th>
<td class="field-body"><tt class="docutils literal">2</tt></td>
</tr>
<tr class="field">
<th class="field-name">Maximum Value:</th>
<td class="field-body"><a class="reference internal"
href="#boost-parameter-compose-max-arity"><tt class="docutils literal"
>BOOST_PARAMETER_COMPOSE_MAX_ARITY</tt></a></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="boost-parameter-compose-max-arity">
<h2><a class="toc-backref" href="#id87">8.7&nbsp;&nbsp;&nbsp;<tt
class="docutils literal">BOOST_PARAMETER_COMPOSE_MAX_ARITY</tt></a></h2>
<p>If <a class="reference internal"
href="#boost-parameter-has-perfect-forwarding"><tt class="docutils literal"
>BOOST_PARAMETER_HAS_PERFECT_FORWARDING</tt></a> is <strong>not</strong>
<tt class="docutils literal">#defined</tt>, then determines the maximum number
of arguments supported by the <a class="reference internal" href="#compose"
><tt class="docutils literal">compose</tt></a> function and by the <a
class="reference internal"
href="#boost-parameter-no-spec-function-result-name"><tt
class="docutils literal">BOOST_PARAMETER_NO_SPEC_FUNCTION</tt></a>, <a
class="reference internal"
href="#boost-parameter-no-spec-member-function-result-name"><tt
class="docutils literal">BOOST_PARAMETER_NO_SPEC_MEMBER_FUNCTION</tt></a>, <a
class="reference internal"
href="#boost-parameter-no-spec-c-mem-function-result-name"><tt
class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONST_MEMBER_FUNCTION</tt></a
>, <a class="reference internal"
href="#boost-parameter-no-spec-function-call-op-result"><tt
class="docutils literal">BOOST_PARAMETER_NO_SPEC_FUNCTION_CALL_OPERATOR</tt
></a>, <a class="reference internal"
href="#boost-parameter-no-spec-const-func-call-op-result"><tt
class="docutils literal"
>BOOST_PARAMETER_NO_SPEC_CONST_FUNCTION_CALL_OPERATOR</tt></a>, <a
class="reference internal"
href="#boost-parameter-no-spec-constructor-cls-impl"><tt
class="docutils literal">BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR</tt></a>, and <a
class="reference internal"
href="#boost-parameter-no-spec-no-base-ctor-cls-func"><tt
class="docutils literal">BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR</tt></a>
code generation macros.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field">
<th class="field-name">Defined in:</th>
<td class="field-body"><a class="reference external"
href="../../../../boost/parameter/config.hpp"
>boost/parameter/config.hpp</a></td>
</tr>
</tbody>
</table>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field">
<th class="field-name">Default Value:</th>
<td class="field-body"><tt class="docutils literal">20</tt> for a few older
compilers, <tt class="docutils literal">64</tt> otherwise</td>
</tr>
<tr class="field">
<th class="field-name">Minimum Value:</th>
<td class="field-body"><tt class="docutils literal">2</tt></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="boost-parameter-exponential-overload-threshold-arity"
><h2><a class="toc-backref" href="#id88">8.7&nbsp;&nbsp;&nbsp;<tt
><h2><a class="toc-backref" href="#id88">8.8&nbsp;&nbsp;&nbsp;<tt
class="docutils literal"
>BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY</tt></a></h2>
<p>If this library does <strong>not</strong> support perfect forwarding,
Expand Down Expand Up @@ -9428,7 +9497,7 @@ <h2><a class="toc-backref" href="#id86">8.6&nbsp;&nbsp;&nbsp;<tt
</table>
</div>
<div class="section" id="outside-of-this-library"
><h2><a class="toc-backref" href="#id89">8.8&nbsp;&nbsp;&nbsp;...Outside Of
><h2><a class="toc-backref" href="#id89">8.9&nbsp;&nbsp;&nbsp;...Outside Of
This Library</a></h2>
<ol>
<li>If <a class="reference external"
Expand Down
23 changes: 22 additions & 1 deletion doc/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ Unlike the |tagged reference| comma operator, the ``compose()`` function is
variadic, as mentioned before. However, the |tagged reference| comma operator
can be invoked indefinitely and therefore does not limit the size of the
resulting |ArgumentPack|, while the ``compose()`` function cannot take in more
than |BOOST_PARAMETER_MAX_ARITY| arguments for compilers that do not
than |BOOST_PARAMETER_COMPOSE_MAX_ARITY| arguments for compilers that do not
support perfect forwarding.

:Requires: ``t0`` and all elements in ``args`` must be |tagged reference|
Expand Down Expand Up @@ -6825,11 +6825,32 @@ __ ../../../../boost/parameter/config.hpp
:Default Value: |BOOST_MPL_LIMIT_VECTOR_SIZE|_ (defined by `Boost.MPL`_) if
perfect forwarding is supported, ``8`` otherwise.
:Minimum Value: ``2``
:Maximum Value: |BOOST_PARAMETER_COMPOSE_MAX_ARITY|

.. |BOOST_MPL_LIMIT_VECTOR_SIZE| replace:: ``BOOST_MPL_LIMIT_VECTOR_SIZE``
.. _BOOST_MPL_LIMIT_VECTOR_SIZE: ../../../mpl/doc/refmanual/limit-vector-size.html
.. _`Boost.MPL`: ../../../mpl/doc/index.html

``BOOST_PARAMETER_COMPOSE_MAX_ARITY``
-------------------------------------

If |BOOST_PARAMETER_HAS_PERFECT_FORWARDING| is **not** ``#defined``, then
determines the maximum number of arguments supported by the |compose| function
and by the |BOOST_PARAMETER_NO_SPEC_FUNCTION|,
|BOOST_PARAMETER_NO_SPEC_MEMBER_FUNCTION|,
|BOOST_PARAMETER_NO_SPEC_CONST_MEMBER_FUNCTION|,
|BOOST_PARAMETER_NO_SPEC_FUNCTION_CALL_OPERATOR|,
|BOOST_PARAMETER_NO_SPEC_CONST_FUNCTION_CALL_OPERATOR|,
|BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR|, and
|BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR| code generation macros.

:Defined in: `boost/parameter/config.hpp`__

__ ../../../../boost/parameter/config.hpp

:Default Value: ``20`` for a few older compilers, ``64`` otherwise
:Minimum Value: ``2``

``BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY``
--------------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions include/boost/parameter/are_tagged_arguments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace boost { namespace parameter {
BOOST_PP_ENUM_PARAMS_Z(z, n, prefix) \
BOOST_PP_ENUM_TRAILING_PARAMS_Z( \
z \
, BOOST_PP_SUB(BOOST_PARAMETER_MAX_ARITY, n) \
, BOOST_PP_SUB(BOOST_PARAMETER_COMPOSE_MAX_ARITY, n) \
, ::boost::parameter::void_ BOOST_PP_INTERCEPT \
) \
> : BOOST_PP_CAT(BOOST_PP_REPEAT_, z)( \
Expand All @@ -96,7 +96,7 @@ namespace boost { namespace parameter {

template <
BOOST_PP_ENUM_BINARY_PARAMS(
BOOST_PP_INC(BOOST_PARAMETER_MAX_ARITY)
BOOST_PP_INC(BOOST_PARAMETER_COMPOSE_MAX_ARITY)
, typename TaggedArg
, = ::boost::parameter::void_ BOOST_PP_INTERCEPT
)
Expand All @@ -110,7 +110,7 @@ namespace boost { namespace parameter {

BOOST_PP_REPEAT_FROM_TO(
1
, BOOST_PP_INC(BOOST_PARAMETER_MAX_ARITY)
, BOOST_PP_INC(BOOST_PARAMETER_COMPOSE_MAX_ARITY)
, BOOST_PARAMETER_ARE_TAGGED_ARGUMENTS_OVERLOADS_Z
, TaggedArg
)
Expand Down
28 changes: 19 additions & 9 deletions include/boost/parameter/aux_/arg_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,11 @@ namespace boost { namespace parameter { namespace aux {
{
}

// Constructor taking BOOST_PARAMETER_MAX_ARITY empty_arg_list
// Constructor taking BOOST_PARAMETER_COMPOSE_MAX_ARITY empty_arg_list
// arguments; this makes initialization.
inline empty_arg_list(
BOOST_PP_ENUM_PARAMS(
BOOST_PARAMETER_MAX_ARITY
BOOST_PARAMETER_COMPOSE_MAX_ARITY
, ::boost::parameter::void_ BOOST_PP_INTERCEPT
)
)
Expand Down Expand Up @@ -488,7 +488,7 @@ namespace boost { namespace parameter { namespace aux {
typedef ::boost::parameter::aux::empty_arg_list type;
};
};
#endif // Borland workarounds needed.
#endif // Borland workarounds needed

// If either of these operators are called, it means there is no
// argument in the list that matches the supplied keyword. Just
Expand Down Expand Up @@ -592,14 +592,24 @@ namespace boost { namespace parameter { namespace aux {
// Store the arguments in successive nodes of this list.
template <
// typename A0, typename A1, ...
BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, typename A)
BOOST_PP_ENUM_PARAMS(
BOOST_PARAMETER_COMPOSE_MAX_ARITY
, typename A
)
>
inline arg_list(
// A0& a0, A1& a1, ...
BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PARAMETER_MAX_ARITY, A, & a)
BOOST_PP_ENUM_BINARY_PARAMS(
BOOST_PARAMETER_COMPOSE_MAX_ARITY
, A
, & a
)
) : Next(
// a1, a2, ...
BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PARAMETER_MAX_ARITY, a)
BOOST_PP_ENUM_SHIFTED_PARAMS(
BOOST_PARAMETER_COMPOSE_MAX_ARITY
, a
)
, ::boost::parameter::aux::void_reference()
)
, arg(a0)
Expand Down Expand Up @@ -660,8 +670,8 @@ namespace boost { namespace parameter { namespace aux {
, duplicate_keyword
, (key_type)
);
#endif
#endif // Borland workarounds not needed.
#endif // SFINAE/MSVC workarounds needed
#endif // Borland workarounds not needed

public:
//
Expand Down Expand Up @@ -856,7 +866,7 @@ namespace boost { namespace parameter { namespace aux {
// Builds an overload set including satisfies functions defined
// in base classes.
using Next::satisfies;
#endif // Borland workarounds needed.
#endif // Borland workarounds needed

// Comma operator to compose argument list without using parameters<>.
// Useful for argument lists with undetermined length.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
#define BOOST_PARAMETER_NO_SPEC_FUNCTION_HEAD(result, name, is_const) \
template < \
BOOST_PP_ENUM_BINARY_PARAMS( \
BOOST_PARAMETER_MAX_ARITY \
BOOST_PARAMETER_COMPOSE_MAX_ARITY \
, typename TaggedArg \
, = ::boost::parameter::void_ BOOST_PP_INTERCEPT \
) \
Expand Down Expand Up @@ -287,7 +287,7 @@
#define BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR(class_, base) \
BOOST_PP_REPEAT_FROM_TO( \
1 \
, BOOST_PP_INC(BOOST_PARAMETER_MAX_ARITY) \
, BOOST_PP_INC(BOOST_PARAMETER_COMPOSE_MAX_ARITY) \
, BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR_OVERLOAD_Z \
, (class_, base) \
)
Expand All @@ -299,7 +299,7 @@
#define BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR(class_, func) \
BOOST_PP_REPEAT_FROM_TO( \
1 \
, BOOST_PP_INC(BOOST_PARAMETER_MAX_ARITY) \
, BOOST_PP_INC(BOOST_PARAMETER_COMPOSE_MAX_ARITY) \
, BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR_OVERLOAD_Z \
, (class_, func) \
)
Expand All @@ -310,7 +310,7 @@
#define BOOST_PARAMETER_NO_SPEC_FUNCTION_OVERLOAD(name, impl, is_m, c) \
BOOST_PP_REPEAT_FROM_TO( \
1 \
, BOOST_PP_INC(BOOST_PARAMETER_MAX_ARITY) \
, BOOST_PP_INC(BOOST_PARAMETER_COMPOSE_MAX_ARITY) \
, BOOST_PARAMETER_NO_SPEC_FUNCTION_OVERLOAD_Z \
, (name, impl, is_m, c) \
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
) \
BOOST_PP_ENUM_TRAILING_PARAMS( \
BOOST_PP_SUB( \
BOOST_PARAMETER_MAX_ARITY \
BOOST_PARAMETER_COMPOSE_MAX_ARITY \
, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(seq)) \
) \
, ::boost::parameter::aux::void_reference() BOOST_PP_INTERCEPT \
Expand Down
6 changes: 3 additions & 3 deletions include/boost/parameter/aux_/preprocessor/overloads.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// >
// , unnamed_list
// >::type
// operator()(A0 const& a0, A1 const& a1) const
// operator()(A0 const& a0, A1 const& a1) const
// {
// typedef typename ::boost::mpl::apply_wrap1<
// ::boost::parameter::aux::make_arg_list<
Expand Down Expand Up @@ -69,7 +69,7 @@ template <BOOST_PP_ENUM_PARAMS(N, typename A)>
typename ::boost::mpl::first<
typename BOOST_PARAMETER_arg_list(N)::type
>::type
operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, & a)) const
operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, & a)) const
{
typedef typename BOOST_PARAMETER_arg_list(N)::type result;
typedef typename ::boost::mpl::first<result>::type result_type;
Expand All @@ -79,7 +79,7 @@ operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, & a)) const
return result_type(
BOOST_PP_ENUM(N, BOOST_PARAMETER_arg_pack_init, BOOST_PP_DEC(N))
BOOST_PP_ENUM_TRAILING_PARAMS(
BOOST_PP_SUB(BOOST_PARAMETER_MAX_ARITY, N)
BOOST_PP_SUB(BOOST_PARAMETER_COMPOSE_MAX_ARITY, N)
, ::boost::parameter::aux::void_reference() BOOST_PP_INTERCEPT
)
);
Expand Down
8 changes: 4 additions & 4 deletions include/boost/parameter/compose.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Cromwell D. Enage 2018.
// Copyright Cromwell D. Enage 2019.
// 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)
Expand Down Expand Up @@ -103,7 +103,7 @@ namespace boost { namespace parameter {
BOOST_PP_ENUM_PARAMS_Z(z, n, a) \
BOOST_PP_ENUM_TRAILING_PARAMS_Z( \
z \
, BOOST_PP_SUB(BOOST_PARAMETER_MAX_ARITY, n) \
, BOOST_PP_SUB(BOOST_PARAMETER_COMPOSE_MAX_ARITY, n) \
, ::boost::parameter::aux::void_reference() BOOST_PP_INTERCEPT \
) \
); \
Expand All @@ -126,7 +126,7 @@ namespace boost { namespace parameter {
BOOST_PP_ENUM_PARAMS_Z(z, n, a) \
BOOST_PP_ENUM_TRAILING_PARAMS_Z( \
z \
, BOOST_PP_SUB(BOOST_PARAMETER_MAX_ARITY, n) \
, BOOST_PP_SUB(BOOST_PARAMETER_COMPOSE_MAX_ARITY, n) \
, ::boost::parameter::aux::void_reference() BOOST_PP_INTERCEPT \
) \
); \
Expand All @@ -141,7 +141,7 @@ namespace boost { namespace parameter {

BOOST_PP_REPEAT_FROM_TO(
1
, BOOST_PP_INC(BOOST_PARAMETER_MAX_ARITY)
, BOOST_PP_INC(BOOST_PARAMETER_COMPOSE_MAX_ARITY)
, BOOST_PARAMETER_compose_arg_list_function_overload
, TaggedArg
)
Expand Down
9 changes: 9 additions & 0 deletions include/boost/parameter/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@
#if !defined(BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY)
#define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY 0
#endif
#if !defined(BOOST_PARAMETER_COMPOSE_MAX_ARITY)
#if BOOST_WORKAROUND(BOOST_MSVC, < 1800)
// Some tests cause MSVC-11.0 and earlier to run out of heap space
// if the value is set any higher. -- Cromwell D. Enage
#define BOOST_PARAMETER_COMPOSE_MAX_ARITY 20
#else
#define BOOST_PARAMETER_COMPOSE_MAX_ARITY 64
#endif
#endif // BOOST_PARAMETER_COMPOSE_MAX_ARITY
#if !defined(BOOST_PARAMETER_MAX_ARITY)
#define BOOST_PARAMETER_MAX_ARITY 8
#endif
Expand Down
Loading

0 comments on commit b531b64

Please sign in to comment.