| 1 | /*! |
| 2 | @file |
| 3 | Forward declares `boost::hana::empty`. |
| 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_EMPTY_HPP |
| 11 | #define BOOST_HANA_FWD_EMPTY_HPP |
| 12 | |
| 13 | #include <boost/hana/config.hpp> |
| 14 | #include <boost/hana/core/when.hpp> |
| 15 | |
| 16 | |
| 17 | namespace boost { namespace hana { |
| 18 | //! Identity of the monadic combination `concat`. |
| 19 | //! @ingroup group-MonadPlus |
| 20 | //! |
| 21 | //! Signature |
| 22 | //! --------- |
| 23 | //! Given a MonadPlus `M`, the signature is |
| 24 | //! @f$ \mathtt{empty}_M : \emptyset \to M(T) @f$. |
| 25 | //! |
| 26 | //! @tparam M |
| 27 | //! The tag of the monadic structure to return. This must be |
| 28 | //! a model of the MonadPlus concept. |
| 29 | //! |
| 30 | //! |
| 31 | //! Example |
| 32 | //! ------- |
| 33 | //! @include example/empty.cpp |
| 34 | #ifdef BOOST_HANA_DOXYGEN_INVOKED |
| 35 | template <typename M> |
| 36 | constexpr auto empty = []() { |
| 37 | return tag-dispatched; |
| 38 | }; |
| 39 | #else |
| 40 | template <typename M, typename = void> |
| 41 | struct empty_impl : empty_impl<M, when<true>> { }; |
| 42 | |
| 43 | template <typename M> |
| 44 | struct empty_t { |
| 45 | constexpr auto operator()() const; |
| 46 | }; |
| 47 | |
| 48 | template <typename M> |
| 49 | BOOST_HANA_INLINE_VARIABLE constexpr empty_t<M> empty{}; |
| 50 | #endif |
| 51 | }} // end namespace boost::hana |
| 52 | |
| 53 | #endif // !BOOST_HANA_FWD_EMPTY_HPP |
| 54 | |