3 Forward declares `boost::hana::ap`.
5 @copyright Louis Dionne 2013-2017
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_HANA_FWD_AP_HPP
11 #define BOOST_HANA_FWD_AP_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
17 namespace boost { namespace hana {
18 //! Lifted application.
19 //! @ingroup group-Applicative
21 //! Specifically, `ap` applies a structure containing functions to a
22 //! structure containing values, and returns a new structure containing
23 //! values. The exact way in which the functions are applied to the values
24 //! depends on the `Applicative`.
26 //! `ap` can be called with two arguments or more; the functions in the `f`
27 //! structure are curried and then applied to the values in each `x...`
28 //! structure using the binary form of `ap`. Note that this requires the
29 //! number of `x...` must match the arity of the functions in the `f`
30 //! structure. In other words, `ap(f, x1, ..., xN)` is equivalent to
32 //! ((curry(f) ap x1) ap x2) ... ap xN
34 //! where `x ap y` is just `ap(x, y)` written in infix notation to
35 //! emphasize the left associativity.
40 //! Given an Applicative `A`, the signature is
41 //! @f$ \mathtt{ap} : A(T_1 \times \cdots \times T_n \to U)
42 //! \times A(T_1) \times \cdots \times A(T_n)
46 //! A structure containing function(s).
49 //! Structure(s) containing value(s) and on which `f` is applied. The
50 //! number of structures must match the arity of the functions in the
56 //! @include example/ap.cpp
59 //! Consider giving access to all the arguments to the tag-dispatched
60 //! implementation for performance purposes.
61 #ifdef BOOST_HANA_DOXYGEN_INVOKED
62 constexpr auto ap = [](auto&& f, auto&& ...x) -> decltype(auto) {
63 return tag-dispatched;
66 template <typename A, typename = void>
67 struct ap_impl : ap_impl<A, when<true>> { };
70 template <typename F, typename X>
71 constexpr decltype(auto) operator()(F&& f, X&& x) const;
73 template <typename F, typename ...Xs>
74 constexpr decltype(auto) operator()(F&& f, Xs&& ...xs) const;
77 BOOST_HANA_INLINE_VARIABLE constexpr ap_t ap{};
79 }} // end namespace boost::hana
81 #endif // !BOOST_HANA_FWD_AP_HPP