Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:13:43

0001 /*!
0002 @file
0003 Forward declares `boost::hana::duplicate`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_HANA_FWD_DUPLICATE_HPP
0011 #define BOOST_HANA_FWD_DUPLICATE_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 #include <boost/hana/core/when.hpp>
0015 
0016 
0017 namespace boost { namespace hana {
0018     //! Add an extra layer of comonadic context to a comonadic value.
0019     //! @ingroup group-Comonad
0020     //!
0021     //! Given a value already in a comonadic context, `duplicate` wraps this
0022     //! value with an additional layer of comonadic context. This can be seen
0023     //! as the dual operation to `flatten` from the Monad concept.
0024     //!
0025     //!
0026     //! Signature
0027     //! ---------
0028     //! Given a Comonad `W`, the signature is
0029     //! \f$
0030     //!     \mathtt{duplicate} : W(T) \to W(W(T))
0031     //! \f$
0032     //!
0033     //! @param w
0034     //! The value to wrap in an additional level of comonadic context.
0035     //!
0036     //!
0037     //! Example
0038     //! -------
0039     //! @include example/duplicate.cpp
0040 #ifdef BOOST_HANA_DOXYGEN_INVOKED
0041     constexpr auto duplicate = [](auto&& w) -> decltype(auto) {
0042         return tag-dispatched;
0043     };
0044 #else
0045     template <typename W, typename = void>
0046     struct duplicate_impl : duplicate_impl<W, when<true>> { };
0047 
0048     struct duplicate_t {
0049         template <typename W_>
0050         constexpr decltype(auto) operator()(W_&& w) const;
0051     };
0052 
0053     BOOST_HANA_INLINE_VARIABLE constexpr duplicate_t duplicate{};
0054 #endif
0055 }} // end namespace boost::hana
0056 
0057 #endif // !BOOST_HANA_FWD_DUPLICATE_HPP