summaryrefslogtreecommitdiff
path: root/boost/hof/is_invocable.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:12:59 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:12:59 +0900
commitb8cf34c691623e4ec329053cbbf68522a855882d (patch)
tree34da08632a99677f6b79ecb65e5b655a5b69a67f /boost/hof/is_invocable.hpp
parent3fdc3e5ee96dca5b11d1694975a65200787eab86 (diff)
downloadboost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.gz
boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.bz2
boost-b8cf34c691623e4ec329053cbbf68522a855882d.zip
Imported Upstream version 1.67.0upstream/1.67.0
Diffstat (limited to 'boost/hof/is_invocable.hpp')
-rw-r--r--boost/hof/is_invocable.hpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/boost/hof/is_invocable.hpp b/boost/hof/is_invocable.hpp
new file mode 100644
index 0000000000..edf736e1b2
--- /dev/null
+++ b/boost/hof/is_invocable.hpp
@@ -0,0 +1,72 @@
+/*=============================================================================
+ Copyright (c) 2014 Paul Fultz II
+ is_invocable.h
+ 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)
+==============================================================================*/
+
+#ifndef BOOST_HOF_GUARD_IS_CALLABLE_H
+#define BOOST_HOF_GUARD_IS_CALLABLE_H
+
+/// is_invocable
+/// ===========
+///
+/// Description
+/// -----------
+///
+/// The `is_invocable` metafunction checks if the function is callable with
+/// certain parameters.
+///
+/// Requirements
+/// ------------
+///
+/// F must be:
+///
+/// * [Invocable](Invocable)
+///
+/// Synopsis
+/// --------
+///
+/// template<class F, class... Ts>
+/// struct is_invocable;
+///
+/// Example
+/// -------
+///
+/// #include <boost/hof.hpp>
+/// using namespace boost::hof;
+///
+/// struct is_invocable_class
+/// {
+/// void operator()(int) const
+/// {
+/// }
+/// };
+/// static_assert(is_invocable<is_invocable_class, int>(), "Not callable");
+///
+/// int main() {}
+///
+
+
+#include <boost/hof/detail/can_be_called.hpp>
+#include <boost/hof/apply.hpp>
+
+namespace boost { namespace hof {
+
+template<class F, class... Ts>
+struct is_invocable
+: detail::can_be_called<detail::apply_f, F, Ts...>
+{};
+
+template<class F, class... Ts, class... Us>
+struct is_invocable<F(Ts...), Us...>
+{
+ static_assert(!std::is_same<F, F>::value,
+ "The is_invocable<F(Args...)> form is not supported because it is problematic."
+ "Please use is_invocable<F, Args...> instead."
+ );
+};
+
+}} // namespace boost::hof
+
+#endif