FIT_STATIC_FUNCTION

Description

The FIT_STATIC_FUNCTION macro allows initializing a function object from a constexpr expression. It also ensures that the function object will have a unique address across translation units. This helps to avoid ODR violations. As such, the object that is deduced is default constructed.

By default, all functions defined with FIT_STATIC_FUNCTION use the reveal adaptor to improve error messages.

Example

#include <fit.hpp>
#include <cassert>

struct sum_f
{
    template<class T, class U>
    T operator()(T x, U y) const
    {
        return x+y;
    }
};

FIT_STATIC_FUNCTION(sum) = sum_f();
FIT_STATIC_FUNCTION(partial_sum) = fit::partial(sum_f());

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