limit

Description

The limit function decorator annotates the function with the max number of parameters. The limit_c version can be used to give the max number directly(instead of relying on an integral constant). The parameter limit can be read by using the function_param_limit trait. Using limit is useful to improve error reporting with partially evaluated functions.

Synopsis

template<class IntegralConstant>
constexpr auto limit(IntegralConstant);

template<std::size_t N, class F>
constexpr auto limit_c(F);

Requirements

IntegralConstant must be:

  • IntegralConstant

F must be:

Example

#include <boost/hof.hpp>
#include <cassert>
using namespace boost::hof;

struct sum_f
{
    template<class T>
    int operator()(T x, T y) const
    {
        return x+y;
    }
};
BOOST_HOF_STATIC_FUNCTION(sum) = limit_c<2>(sum_f());

int main() {
    assert(3 == sum(1, 2));
}