mirror of
https://github.com/boostorg/hof.git
synced 2026-02-08 23:02:11 +00:00
Boostify
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
#include <fit/lambda.hpp>
|
||||
#include <fit/conditional.hpp>
|
||||
#include <fit/partial.hpp>
|
||||
#include <fit/infix.hpp>
|
||||
#include <fit/pipable.hpp>
|
||||
#include <boost/fit/lambda.hpp>
|
||||
#include <boost/fit/conditional.hpp>
|
||||
#include <boost/fit/partial.hpp>
|
||||
#include <boost/fit/infix.hpp>
|
||||
#include <boost/fit/pipable.hpp>
|
||||
#include <memory>
|
||||
#include "test.hpp"
|
||||
|
||||
#if FIT_HAS_STATIC_LAMBDA
|
||||
static constexpr auto add_one = FIT_STATIC_LAMBDA(int x)
|
||||
#if BOOST_FIT_HAS_STATIC_LAMBDA
|
||||
static constexpr auto add_one = BOOST_FIT_STATIC_LAMBDA(int x)
|
||||
{
|
||||
return x + 1;
|
||||
};
|
||||
@@ -15,7 +15,7 @@ static constexpr auto add_one = FIT_STATIC_LAMBDA(int x)
|
||||
template<class F>
|
||||
struct wrapper : F
|
||||
{
|
||||
FIT_INHERIT_CONSTRUCTOR(wrapper, F)
|
||||
BOOST_FIT_INHERIT_CONSTRUCTOR(wrapper, F)
|
||||
};
|
||||
|
||||
template<class T>
|
||||
@@ -24,69 +24,69 @@ constexpr wrapper<T> wrap(T x)
|
||||
return x;
|
||||
}
|
||||
|
||||
FIT_TEST_CASE()
|
||||
BOOST_FIT_TEST_CASE()
|
||||
{
|
||||
FIT_TEST_CHECK(3 == add_one(2));
|
||||
BOOST_FIT_TEST_CHECK(3 == add_one(2));
|
||||
}
|
||||
|
||||
FIT_TEST_CASE()
|
||||
BOOST_FIT_TEST_CASE()
|
||||
{
|
||||
constexpr auto add_one_again = add_one;
|
||||
FIT_TEST_CHECK(3 == add_one_again(2));
|
||||
BOOST_FIT_TEST_CHECK(3 == add_one_again(2));
|
||||
}
|
||||
|
||||
FIT_TEST_CASE()
|
||||
BOOST_FIT_TEST_CASE()
|
||||
{
|
||||
constexpr auto add_one_again = wrap(add_one);
|
||||
FIT_TEST_CHECK(3 == add_one_again(2));
|
||||
BOOST_FIT_TEST_CHECK(3 == add_one_again(2));
|
||||
}
|
||||
|
||||
namespace test_static {
|
||||
|
||||
FIT_STATIC_LAMBDA_FUNCTION(add_one) = [](int x)
|
||||
BOOST_FIT_STATIC_LAMBDA_FUNCTION(add_one) = [](int x)
|
||||
{
|
||||
return x + 1;
|
||||
};
|
||||
|
||||
FIT_STATIC_LAMBDA_FUNCTION(sum_partial) = fit::partial([](int x, int y)
|
||||
BOOST_FIT_STATIC_LAMBDA_FUNCTION(sum_partial) = boost::fit::partial([](int x, int y)
|
||||
{
|
||||
return x + y;
|
||||
});
|
||||
|
||||
FIT_TEST_CASE()
|
||||
BOOST_FIT_TEST_CASE()
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
STATIC_ASSERT_EMPTY(sum_partial);
|
||||
#endif
|
||||
FIT_TEST_CHECK(3 == sum_partial(1, 2));
|
||||
FIT_TEST_CHECK(3 == sum_partial(1)(2));
|
||||
BOOST_FIT_TEST_CHECK(3 == sum_partial(1, 2));
|
||||
BOOST_FIT_TEST_CHECK(3 == sum_partial(1)(2));
|
||||
}
|
||||
|
||||
FIT_STATIC_LAMBDA_FUNCTION(add_one_pipable) = fit::pipable([](int x)
|
||||
BOOST_FIT_STATIC_LAMBDA_FUNCTION(add_one_pipable) = boost::fit::pipable([](int x)
|
||||
{
|
||||
return x + 1;
|
||||
});
|
||||
|
||||
FIT_TEST_CASE()
|
||||
BOOST_FIT_TEST_CASE()
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
STATIC_ASSERT_EMPTY(add_one_pipable);
|
||||
#endif
|
||||
FIT_TEST_CHECK(3 == add_one_pipable(2));
|
||||
FIT_TEST_CHECK(3 == (2 | add_one_pipable));
|
||||
BOOST_FIT_TEST_CHECK(3 == add_one_pipable(2));
|
||||
BOOST_FIT_TEST_CHECK(3 == (2 | add_one_pipable));
|
||||
}
|
||||
|
||||
FIT_STATIC_LAMBDA_FUNCTION(sum_infix) = fit::infix([](int x, int y)
|
||||
BOOST_FIT_STATIC_LAMBDA_FUNCTION(sum_infix) = boost::fit::infix([](int x, int y)
|
||||
{
|
||||
return x + y;
|
||||
});
|
||||
|
||||
FIT_TEST_CASE()
|
||||
BOOST_FIT_TEST_CASE()
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
STATIC_ASSERT_EMPTY(sum_infix);
|
||||
#endif
|
||||
FIT_TEST_CHECK(3 == (1 <sum_infix> 2));
|
||||
BOOST_FIT_TEST_CHECK(3 == (1 <sum_infix> 2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user