/*============================================================================= Copyright (c) 2017 Paul Fultz II placeholders.cpp 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) ==============================================================================*/ #include #include "test.hpp" #include // TODO: Test assign operators #if BOOST_HOF_HAS_STATIC_TEST_CHECK #define BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR constexpr #else #define BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR #endif struct square { template BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto operator()(T x) const BOOST_HOF_RETURNS(x*x); }; #define CHECK_DEFAULT_CONSTRUCTION_OP(op, name) \ static_assert(boost::hof::detail::is_default_constructible::value, "Operator not default constructible"); #if BOOST_HOF_HAS_NOEXCEPT_DEDUCTION #define PLACEHOLDER_CHECK(...) \ BOOST_HOF_STATIC_TEST_CHECK(__VA_ARGS__); \ BOOST_HOF_TEST_CHECK(__VA_ARGS__); \ static_assert(noexcept(__VA_ARGS__), "noexcept placeholders") #else #define PLACEHOLDER_CHECK(...) \ BOOST_HOF_STATIC_TEST_CHECK(__VA_ARGS__); \ BOOST_HOF_TEST_CHECK(__VA_ARGS__) #endif BOOST_HOF_TEST_CASE() { static_assert(boost::hof::detail::is_default_constructible>::value, "Placeholder not default constructible"); static_assert(boost::hof::detail::is_default_constructible>::value, "Placeholder not default constructible"); static_assert(boost::hof::detail::is_default_constructible>::value, "Placeholder not default constructible"); BOOST_HOF_FOREACH_BINARY_OP(CHECK_DEFAULT_CONSTRUCTION_OP) BOOST_HOF_FOREACH_ASSIGN_OP(CHECK_DEFAULT_CONSTRUCTION_OP) BOOST_HOF_FOREACH_UNARY_OP(CHECK_DEFAULT_CONSTRUCTION_OP) } BOOST_HOF_TEST_CASE() { auto simple_print = boost::hof::reveal(std::ref(std::cout) << boost::hof::_); simple_print("Hello"); } BOOST_HOF_TEST_CASE() { std::stringstream ss; auto simple_print = boost::hof::reveal(std::ref(ss) << boost::hof::_); simple_print("Hello"); BOOST_HOF_TEST_CHECK(ss.str() == "Hello"); } BOOST_HOF_TEST_CASE() { const auto x_square_add = 2 + (4*4); BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_square_add = boost::hof::_1 + boost::hof::lazy(square())(boost::hof::_2); #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif PLACEHOLDER_CHECK(f_square_add(2, 4) == x_square_add); } BOOST_HOF_TEST_CASE() { BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_invoke_2 = boost::hof::_1(3); #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif PLACEHOLDER_CHECK(f_invoke_2(square()) == 9); } BOOST_HOF_TEST_CASE() { const auto x_add = 2 + 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_add = boost::hof::_1 + boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_add(2, 1) == x_add); const auto x_subtract = 2 - 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_subtract = boost::hof::_1 - boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_subtract(2, 1) == x_subtract); const auto x_multiply = 2 * 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_multiply = boost::hof::_1 * boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_multiply(2, 1) == x_multiply); const auto x_divide = 2 / 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_divide = boost::hof::_1 / boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_divide(2, 1) == x_divide); const auto x_remainder = 2 % 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_remainder = boost::hof::_1 % boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_remainder(2, 1) == x_remainder); const auto x_shift_right = 2 >> 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_right = boost::hof::_1 >> boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_shift_right(2, 1) == x_shift_right); const auto x_shift_left = 2 << 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_left = boost::hof::_1 << boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_shift_left(2, 1) == x_shift_left); const auto x_greater_than = 2 > 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than = boost::hof::_1 > boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_greater_than(2, 1) == x_greater_than); const auto x_less_than = 2 < 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than = boost::hof::_1 < boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_less_than(2, 1) == x_less_than); const auto x_less_than_equal = 2 <= 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than_equal = boost::hof::_1 <= boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_less_than_equal(2, 1) == x_less_than_equal); const auto x_greater_than_equal = 2 >= 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than_equal = boost::hof::_1 >= boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_greater_than_equal(2, 1) == x_greater_than_equal); const auto x_equal = 2 == 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_equal = boost::hof::_1 == boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_equal(2, 1) == x_equal); const auto x_not_equal = 2 != 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_equal = boost::hof::_1 != boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_not_equal(2, 1) == x_not_equal); const auto x_bit_and = 2 & 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_and = boost::hof::_1 & boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_bit_and(2, 1) == x_bit_and); const auto x_xor_ = 2 ^ 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_xor_ = boost::hof::_1 ^ boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_xor_(2, 1) == x_xor_); const auto x_bit_or = 2 | 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_or = boost::hof::_1 | boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_bit_or(2, 1) == x_bit_or); const auto x_and_ = true && false; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_and_ = boost::hof::_1 && boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_and_(true, false) == x_and_); const auto x_or_ = true; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_or_ = boost::hof::_1 || boost::hof::_2; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_or_(true, false) == x_or_); } BOOST_HOF_TEST_CASE() { const auto x_not_ = !false; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_ = !boost::hof::_1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_not_(false) == x_not_); const auto x_not_0 = !0; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_0 = !boost::hof::_1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_not_0(0) == x_not_0); const auto x_compl_ = ~2; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_compl_ = ~boost::hof::_1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_compl_(2) == x_compl_); const auto x_unary_plus = +2; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_unary_plus = +boost::hof::_1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_unary_plus(2) == x_unary_plus); const auto x_unary_subtract = -2; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_unary_subtract = -boost::hof::_1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_unary_subtract(2) == x_unary_subtract); const auto x_dereference = 2; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_dereference = *boost::hof::_1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_dereference(&x_dereference) == x_dereference); // TODO: Test BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR increment and decrement #ifndef _MSC_VER auto x_increment = 2; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_increment = ++boost::hof::_1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); f_increment(x_increment); BOOST_HOF_TEST_CHECK(x_increment == 3); auto x_decrement = 2; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_decrement = --boost::hof::_1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); f_decrement(x_decrement); BOOST_HOF_TEST_CHECK(x_decrement == 1); #endif // TODO: Test post increment and decrement } BOOST_HOF_TEST_CASE() { const auto x_add = 2 + 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_add = boost::hof::_ + boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_add(2, 1) == x_add); const auto x_subtract = 2 - 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_subtract = boost::hof::_ - boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_subtract(2, 1) == x_subtract); const auto x_multiply = 2 * 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_multiply = boost::hof::_ * boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_multiply(2, 1) == x_multiply); const auto x_divide = 2 / 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_divide = boost::hof::_ / boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_divide(2, 1) == x_divide); const auto x_remainder = 2 % 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_remainder = boost::hof::_ % boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_remainder(2, 1) == x_remainder); const auto x_shift_right = 2 >> 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_right = boost::hof::_ >> boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_shift_right(2, 1) == x_shift_right); const auto x_shift_left = 2 << 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_left = boost::hof::_ << boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_shift_left(2, 1) == x_shift_left); const auto x_greater_than = 2 > 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than = boost::hof::_ > boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_greater_than(2, 1) == x_greater_than); const auto x_less_than = 2 < 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than = boost::hof::_ < boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_less_than(2, 1) == x_less_than); const auto x_less_than_equal = 2 <= 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than_equal = boost::hof::_ <= boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_less_than_equal(2, 1) == x_less_than_equal); const auto x_greater_than_equal = 2 >= 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than_equal = boost::hof::_ >= boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_greater_than_equal(2, 1) == x_greater_than_equal); const auto x_equal = 2 == 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_equal = boost::hof::_ == boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_equal(2, 1) == x_equal); const auto x_not_equal = 2 != 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_equal = boost::hof::_ != boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_not_equal(2, 1) == x_not_equal); const auto x_bit_and = 2 & 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_and = boost::hof::_ & boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_bit_and(2, 1) == x_bit_and); const auto x_xor_ = 2 ^ 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_xor_ = boost::hof::_ ^ boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_xor_(2, 1) == x_xor_); const auto x_bit_or = 2 | 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_or = boost::hof::_ | boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_bit_or(2, 1) == x_bit_or); const auto x_and_ = true && false; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_and_ = boost::hof::_ && boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_and_(true, false) == x_and_); const auto x_or_ = true; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_or_ = boost::hof::_ || boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_or_(true, false) == x_or_); } BOOST_HOF_TEST_CASE() { const auto x_add = 2 + 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_add = 2 + boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_add(1) == x_add); const auto x_subtract = 2 - 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_subtract = 2 - boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_subtract(1) == x_subtract); const auto x_multiply = 2 * 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_multiply = 2 * boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_multiply(1) == x_multiply); const auto x_divide = 2 / 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_divide = 2 / boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_divide(1) == x_divide); const auto x_remainder = 2 % 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_remainder = 2 % boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_remainder(1) == x_remainder); const auto x_shift_right = 2 >> 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_right = 2 >> boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_shift_right(1) == x_shift_right); const auto x_shift_left = 2 << 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_left = 2 << boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_shift_left(1) == x_shift_left); const auto x_greater_than = 2 > 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than = 2 > boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_greater_than(1) == x_greater_than); const auto x_less_than = 2 < 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than = 2 < boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_less_than(1) == x_less_than); const auto x_less_than_equal = 2 <= 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than_equal = 2 <= boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_less_than_equal(1) == x_less_than_equal); const auto x_greater_than_equal = 2 >= 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than_equal = 2 >= boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_greater_than_equal(1) == x_greater_than_equal); const auto x_equal = 2 == 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_equal = 2 == boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_equal(1) == x_equal); const auto x_not_equal = 2 != 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_equal = 2 != boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_not_equal(1) == x_not_equal); const auto x_bit_and = 2 & 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_and = 2 & boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_bit_and(1) == x_bit_and); const auto x_xor_ = 2 ^ 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_xor_ = 2 ^ boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_xor_(1) == x_xor_); const auto x_bit_or = 2 | 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_or = 2 | boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_bit_or(1) == x_bit_or); const auto x_and_ = true && false; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_and_ = true && boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_and_(false) == x_and_); const auto x_or_ = true; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_or_ = true || boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_or_(false) == x_or_); } BOOST_HOF_TEST_CASE() { const auto x_add = 2 + 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_add = boost::hof::_ + 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_add(2) == x_add); const auto x_subtract = 2 - 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_subtract = boost::hof::_ - 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_subtract(2) == x_subtract); const auto x_multiply = 2 * 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_multiply = boost::hof::_ * 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_multiply(2) == x_multiply); const auto x_divide = 2 / 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_divide = boost::hof::_ / 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_divide(2) == x_divide); const auto x_remainder = 2 % 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_remainder = boost::hof::_ % 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_remainder(2) == x_remainder); const auto x_shift_right = 2 >> 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_right = boost::hof::_ >> 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_shift_right(2) == x_shift_right); const auto x_shift_left = 2 << 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_left = boost::hof::_ << 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_shift_left(2) == x_shift_left); const auto x_greater_than = 2 > 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than = boost::hof::_ > 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_greater_than(2) == x_greater_than); const auto x_less_than = 2 < 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than = boost::hof::_ < 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_less_than(2) == x_less_than); const auto x_less_than_equal = 2 <= 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than_equal = boost::hof::_ <= 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_less_than_equal(2) == x_less_than_equal); const auto x_greater_than_equal = 2 >= 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than_equal = boost::hof::_ >= 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_greater_than_equal(2) == x_greater_than_equal); const auto x_equal = 2 == 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_equal = boost::hof::_ == 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_equal(2) == x_equal); const auto x_not_equal = 2 != 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_equal = boost::hof::_ != 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_not_equal(2) == x_not_equal); const auto x_bit_and = 2 & 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_and = boost::hof::_ & 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_bit_and(2) == x_bit_and); const auto x_xor_ = 2 ^ 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_xor_ = boost::hof::_ ^ 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_xor_(2) == x_xor_); const auto x_bit_or = 2 | 1; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_or = boost::hof::_ | 1; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_bit_or(2) == x_bit_or); const auto x_and_ = true && false; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_and_ = boost::hof::_ && false; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_and_(true) == x_and_); const auto x_or_ = true; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_or_ = boost::hof::_ || false; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(!boost::hof::detail::is_default_constructible::value, "default constructible"); PLACEHOLDER_CHECK(f_or_(true) == x_or_); } BOOST_HOF_TEST_CASE() { const auto x_not_ = !false; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_ = !boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_not_(false) == x_not_); const auto x_compl_ = ~2; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_compl_ = ~boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_compl_(2) == x_compl_); const auto x_unary_plus = +2; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_unary_plus = +boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_unary_plus(2) == x_unary_plus); const auto x_unary_subtract = -2; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_unary_subtract = -boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_unary_subtract(2) == x_unary_subtract); const auto x_dereference = 2; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_dereference = *boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); PLACEHOLDER_CHECK(f_dereference(&x_dereference) == x_dereference); // TODO: Test constexpr increment and decrement #ifndef _MSC_VER auto x_increment = 2; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_increment = ++boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); f_increment(x_increment); BOOST_HOF_TEST_CHECK(x_increment == 3); auto x_decrement = 2; BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_decrement = --boost::hof::_; #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 static_assert(std::is_copy_constructible::value, "Not copyable"); #endif static_assert(boost::hof::detail::is_default_constructible::value, "Not default constructible"); f_decrement(x_decrement); BOOST_HOF_TEST_CHECK(x_decrement == 1); #endif // TODO: Test post increment and decrement }