mirror of
https://github.com/boostorg/hof.git
synced 2026-01-22 17:22:35 +00:00
40 lines
602 B
C++
40 lines
602 B
C++
#include <fit/lambda.h>
|
|
#include <fit/conditional.h>
|
|
#include <memory>
|
|
#include "test.h"
|
|
|
|
static constexpr auto add_one = FIT_STATIC_LAMBDA(int x)
|
|
{
|
|
return x + 1;
|
|
};
|
|
|
|
template<class F>
|
|
struct wrapper : F
|
|
{
|
|
FIT_INHERIT_CONSTRUCTOR(wrapper, F)
|
|
};
|
|
|
|
template<class T>
|
|
constexpr wrapper<T> wrap(T x)
|
|
{
|
|
return x;
|
|
}
|
|
|
|
FIT_TEST_CASE()
|
|
{
|
|
FIT_TEST_CHECK(3 == add_one(2));
|
|
}
|
|
|
|
FIT_TEST_CASE()
|
|
{
|
|
constexpr auto add_one_again = add_one;
|
|
FIT_TEST_CHECK(3 == add_one_again(2));
|
|
}
|
|
|
|
FIT_TEST_CASE()
|
|
{
|
|
constexpr auto add_one_again = wrap(add_one);
|
|
FIT_TEST_CHECK(3 == add_one_again(2));
|
|
}
|
|
|