]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Forward declares `boost::hana::extract`. | |
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_EXTRACT_HPP | |
11 | #define BOOST_HANA_FWD_EXTRACT_HPP | |
12 | ||
13 | #include <boost/hana/config.hpp> | |
14 | #include <boost/hana/core/when.hpp> | |
15 | ||
16 | ||
17 | BOOST_HANA_NAMESPACE_BEGIN | |
18 | //! Extract a value in a given comonadic context. | |
19 | //! @ingroup group-Comonad | |
20 | //! | |
21 | //! Given a value inside a comonadic context, extract it from that | |
22 | //! context, performing whatever effects are mandated by that context. | |
23 | //! This can be seen as the dual operation to the `lift` method of the | |
24 | //! Applicative concept. | |
25 | //! | |
26 | //! | |
27 | //! Signature | |
28 | //! --------- | |
29 | //! Given a Comonad `W`, the signature is | |
30 | //! \f$ | |
31 | //! \mathtt{extract} : W(T) \to T | |
32 | //! \f$ | |
33 | //! | |
34 | //! @param w | |
35 | //! The value to be extracted inside a comonadic context. | |
36 | //! | |
37 | //! | |
38 | //! Example | |
39 | //! ------- | |
40 | //! @include example/extract.cpp | |
41 | #ifdef BOOST_HANA_DOXYGEN_INVOKED | |
42 | constexpr auto extract = [](auto&& w) -> decltype(auto) { | |
43 | return tag-dispatched; | |
44 | }; | |
45 | #else | |
46 | template <typename W, typename = void> | |
47 | struct extract_impl : extract_impl<W, when<true>> { }; | |
48 | ||
49 | struct extract_t { | |
50 | template <typename W_> | |
51 | constexpr decltype(auto) operator()(W_&& w) const; | |
52 | }; | |
53 | ||
54 | constexpr extract_t extract{}; | |
55 | #endif | |
56 | BOOST_HANA_NAMESPACE_END | |
57 | ||
58 | #endif // !BOOST_HANA_FWD_EXTRACT_HPP |