]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Forward declares `boost::hana::extend`. | |
4 | ||
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) | |
8 | */ | |
9 | ||
10 | #ifndef BOOST_HANA_FWD_EXTEND_HPP | |
11 | #define BOOST_HANA_FWD_EXTEND_HPP | |
12 | ||
13 | #include <boost/hana/config.hpp> | |
14 | #include <boost/hana/core/when.hpp> | |
15 | ||
16 | ||
17 | BOOST_HANA_NAMESPACE_BEGIN | |
18 | //! Comonadic application of a function to a comonadic value. | |
19 | //! @ingroup group-Comonad | |
20 | //! | |
21 | //! Given a comonadic value and a function accepting a comonadic input, | |
22 | //! `extend` returns the result of applying the function to that input | |
23 | //! inside the comonadic context. | |
24 | //! | |
25 | //! | |
26 | //! Signature | |
27 | //! --------- | |
28 | //! Given a Comonad `W` and a function of type \f$ W(T) \to U \f$, the | |
29 | //! signature is | |
30 | //! \f$ | |
31 | //! \mathtt{extend} : W(T) \times (W(T) \to U) \to W(U) | |
32 | //! \f$ | |
33 | //! | |
34 | //! @param w | |
35 | //! A comonadic value to call the function with. | |
36 | //! | |
37 | //! @param f | |
38 | //! A function of signature \f$ W(T) \to U \f$ to be applied to its | |
39 | //! comonadic argument inside the comonadic context. | |
40 | //! | |
41 | //! | |
42 | //! Example | |
43 | //! ------- | |
44 | //! @include example/extend.cpp | |
45 | #ifdef BOOST_HANA_DOXYGEN_INVOKED | |
46 | constexpr auto extend = [](auto&& w, auto&& f) -> decltype(auto) { | |
47 | return tag-dispatched; | |
48 | }; | |
49 | #else | |
50 | template <typename W, typename = void> | |
51 | struct extend_impl : extend_impl<W, when<true>> { }; | |
52 | ||
53 | struct extend_t { | |
54 | template <typename W_, typename F> | |
55 | constexpr decltype(auto) operator()(W_&& w, F&& f) const; | |
56 | }; | |
57 | ||
58 | constexpr extend_t extend{}; | |
59 | #endif | |
60 | BOOST_HANA_NAMESPACE_END | |
61 | ||
62 | #endif // !BOOST_HANA_FWD_EXTEND_HPP |