3 Forward declares `boost::hana::ap`.
5 @copyright Louis Dionne 2013-2016
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 BOOST_HANA_NAMESPACE_BEGIN
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 //! ((f' <ap> x1) <ap> x2) ... <ap> xN
34 //! where `f'` is `f` but containing curried functions instead and
35 //! `x <ap> y` is just `ap(x, y)` written in infix notation to emphasize
36 //! the left associativity.
41 //! Given an Applicative `A`, the signature is
42 //! @f$ \mathtt{ap} : A(T_1 \times \cdots \times T_n \to U)
43 //! \times A(T_1) \times \cdots \times A(T_n)
47 //! A structure containing function(s).
50 //! Structure(s) containing value(s) and on which `f` is applied. The
51 //! number of structures must match the arity of the functions in the
57 //! @include example/ap.cpp
60 //! Consider giving access to all the arguments to the tag-dispatched
61 //! implementation for performance purposes.
62 #ifdef BOOST_HANA_DOXYGEN_INVOKED
63 constexpr auto ap = [](auto&& f, auto&& ...x) -> decltype(auto) {
64 return tag-dispatched;
67 template <typename A, typename = void>
68 struct ap_impl : ap_impl<A, when<true>> { };
71 template <typename F, typename X>
72 constexpr decltype(auto) operator()(F&& f, X&& x) const;
74 template <typename F, typename ...Xs>
75 constexpr decltype(auto) operator()(F&& f, Xs&& ...xs) const;
80 BOOST_HANA_NAMESPACE_END
82 #endif // !BOOST_HANA_FWD_AP_HPP