| 1 | /*! |
| 2 | @file |
| 3 | Forward declares `boost::hana::extract`. |
| 4 | |
| 5 | Copyright Louis Dionne 2013-2022 |
| 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 |
| 12 | |
| 13 | #include <boost/hana/config.hpp> |
| 14 | #include <boost/hana/core/when.hpp> |
| 15 | |
| 16 | |
| 17 | namespace boost { namespace hana { |
| 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<W, when<true>> { }; |
| 48 | |
| 49 | struct { |
| 50 | template <typename W_> |
| 51 | constexpr decltype(auto) (W_&& w) const; |
| 52 | }; |
| 53 | |
| 54 | BOOST_HANA_INLINE_VARIABLE constexpr extract_t {}; |
| 55 | #endif |
| 56 | }} // end namespace boost::hana |
| 57 | |
| 58 | #endif // !BOOST_HANA_FWD_EXTRACT_HPP |
| 59 | |