From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/hof/test/is_invocable.cpp | 192 +++++++++++++++++++++++++++++++ 1 file changed, 192 insertions(+) create mode 100644 src/boost/libs/hof/test/is_invocable.cpp (limited to 'src/boost/libs/hof/test/is_invocable.cpp') diff --git a/src/boost/libs/hof/test/is_invocable.cpp b/src/boost/libs/hof/test/is_invocable.cpp new file mode 100644 index 00000000..e65d49c1 --- /dev/null +++ b/src/boost/libs/hof/test/is_invocable.cpp @@ -0,0 +1,192 @@ +/*============================================================================= + Copyright (c) 2017 Paul Fultz II + is_invocable.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 +#include "test.hpp" + +template +struct callable_rank : callable_rank +{}; + +template<> +struct callable_rank<0> +{}; + +BOOST_HOF_STATIC_TEST_CASE() +{ + struct is_callable_class + { + void operator()(int) const + { + } + }; + struct callable_test_param {}; + + void is_callable_function(int) + { + } + + struct is_callable_rank_class + { + void operator()(int, callable_rank<3>) const + { + } + + void operator()(int, callable_rank<4>) const + { + } + }; + + static_assert(boost::hof::is_invocable::value, "Not callable"); + static_assert(boost::hof::is_invocable::value, "Not callable"); + static_assert(boost::hof::is_invocable::value, "Not callable"); + static_assert(boost::hof::is_invocable::value, "Not callable"); + static_assert(boost::hof::is_invocable::value, "Not callable"); + static_assert(boost::hof::is_invocable::value, "Not callable"); + static_assert(not boost::hof::is_invocable::value, "callable failed"); + static_assert(not boost::hof::is_invocable::value, "callable failed"); + static_assert(not boost::hof::is_invocable::value, "callable failed"); + + typedef void (*is_callable_function_pointer)(int); + static_assert(boost::hof::is_invocable::value, "Not callable"); + static_assert(boost::hof::is_invocable::value, "Not callable"); + static_assert(boost::hof::is_invocable::value, "Not callable"); + static_assert(boost::hof::is_invocable::value, "Not callable"); + static_assert(boost::hof::is_invocable::value, "Not callable"); + static_assert(boost::hof::is_invocable::value, "Not callable"); + static_assert(not boost::hof::is_invocable::value, "callable failed"); + static_assert(not boost::hof::is_invocable::value, "callable failed"); + static_assert(not boost::hof::is_invocable::value, "callable failed"); + + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + static_assert(boost::hof::is_invocable>::value, "Not callable"); + + static_assert(not boost::hof::is_invocable>::value, "callable failed"); + static_assert(not boost::hof::is_invocable>::value, "callable failed"); + static_assert(not boost::hof::is_invocable>::value, "callable failed"); + static_assert(not boost::hof::is_invocable>::value, "callable failed"); + static_assert(not boost::hof::is_invocable>::value, "callable failed"); + static_assert(not boost::hof::is_invocable>::value, "callable failed"); + + static_assert(not boost::hof::is_invocable::value, "callable failed"); + static_assert(not boost::hof::is_invocable, callable_test_param>::value, "callable failed"); + static_assert(not boost::hof::is_invocable, callable_test_param>::value, "callable failed"); + static_assert(not boost::hof::is_invocable>::value, "callable failed"); + static_assert(not boost::hof::is_invocable>::value, "callable failed"); + static_assert(not boost::hof::is_invocable::value, "callable failed"); + static_assert(not boost::hof::is_invocable::value, "callable failed"); +}; + +BOOST_HOF_STATIC_TEST_CASE() +{ + typedef int(callable_rank<0>::*fn)(int); + + static_assert(boost::hof::is_invocable&, int>::value, "Failed"); + static_assert(boost::hof::is_invocable&, int>::value, "Failed"); + static_assert(!boost::hof::is_invocable&>::value, "Failed"); + static_assert(!boost::hof::is_invocable const&, int>::value, "Failed"); +}; + +BOOST_HOF_STATIC_TEST_CASE() +{ + typedef int(callable_rank<0>::*fn)(int); + + typedef callable_rank<0>* T; + typedef callable_rank<1>* DT; + typedef const callable_rank<0>* CT; + typedef std::unique_ptr> ST; + + static_assert(boost::hof::is_invocable::value, "Failed"); + static_assert(boost::hof::is_invocable::value, "Failed"); + static_assert(boost::hof::is_invocable::value, "Failed"); + static_assert(boost::hof::is_invocable::value, "Failed"); + static_assert(boost::hof::is_invocable::value, "Failed"); + static_assert(!boost::hof::is_invocable::value, "Failed"); + +}; + +BOOST_HOF_STATIC_TEST_CASE() +{ + typedef int(callable_rank<0>::*fn); + + static_assert(!boost::hof::is_invocable::value, "Failed"); +}; + +BOOST_HOF_STATIC_TEST_CASE() +{ + typedef int(callable_rank<0>::*fn); + + static_assert(boost::hof::is_invocable&>::value, "Failed"); + static_assert(boost::hof::is_invocable&&>::value, "Failed"); + static_assert(boost::hof::is_invocable&>::value, "Failed"); + static_assert(boost::hof::is_invocable&>::value, "Failed"); +}; + +BOOST_HOF_STATIC_TEST_CASE() +{ + typedef int(callable_rank<0>::*fn); + + typedef callable_rank<0>* T; + typedef callable_rank<1>* DT; + typedef const callable_rank<0>* CT; + typedef std::unique_ptr> ST; + + static_assert(boost::hof::is_invocable::value, "Failed"); + static_assert(boost::hof::is_invocable::value, "Failed"); + static_assert(boost::hof::is_invocable::value, "Failed"); + static_assert(boost::hof::is_invocable::value, "Failed"); + static_assert(boost::hof::is_invocable::value, "Failed"); + static_assert(boost::hof::is_invocable::value, "Failed"); + +}; + +BOOST_HOF_STATIC_TEST_CASE() +{ + typedef void(*fp)(callable_rank<0>&, int); + + static_assert(boost::hof::is_invocable&, int>::value, "Failed"); + static_assert(boost::hof::is_invocable&, int>::value, "Failed"); + static_assert(!boost::hof::is_invocable&, int>::value, "Failed"); + static_assert(!boost::hof::is_invocable::value, "Failed"); + static_assert(!boost::hof::is_invocable&>::value, "Failed"); +}; + +BOOST_HOF_STATIC_TEST_CASE() +{ + typedef void(&fp)(callable_rank<0>&, int); + + static_assert(boost::hof::is_invocable&, int>::value, "Failed"); + static_assert(boost::hof::is_invocable&, int>::value, "Failed"); + static_assert(!boost::hof::is_invocable&, int>::value, "Failed"); + static_assert(!boost::hof::is_invocable::value, "Failed"); + static_assert(!boost::hof::is_invocable&>::value, "Failed"); +}; -- cgit v1.2.3