3 Forward declares `boost::hana::duplicate`.
5 @copyright Louis Dionne 2013-2017
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_DUPLICATE_HPP
11 #define BOOST_HANA_FWD_DUPLICATE_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Add an extra layer of comonadic context to a comonadic value.
19 //! @ingroup group-Comonad
21 //! Given a value already in a comonadic context, `duplicate` wraps this
22 //! value with an additional layer of comonadic context. This can be seen
23 //! as the dual operation to `flatten` from the Monad concept.
28 //! Given a Comonad `W`, the signature is
30 //! \mathtt{duplicate} : W(T) \to W(W(T))
34 //! The value to wrap in an additional level of comonadic context.
39 //! @include example/duplicate.cpp
40 #ifdef BOOST_HANA_DOXYGEN_INVOKED
41 constexpr auto duplicate = [](auto&& w) -> decltype(auto) {
42 return tag-dispatched;
45 template <typename W, typename = void>
46 struct duplicate_impl : duplicate_impl<W, when<true>> { };
49 template <typename W_>
50 constexpr decltype(auto) operator()(W_&& w) const;
53 constexpr duplicate_t duplicate{};
55 BOOST_HANA_NAMESPACE_END
57 #endif // !BOOST_HANA_FWD_DUPLICATE_HPP