empty.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*!
  2. @file
  3. Forward declares `boost::hana::empty`.
  4. @copyright Louis Dionne 2013-2016
  5. Distributed under the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef BOOST_HANA_FWD_EMPTY_HPP
  9. #define BOOST_HANA_FWD_EMPTY_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Identity of the monadic combination `concat`.
  14. //! @ingroup group-MonadPlus
  15. //!
  16. //! Signature
  17. //! ---------
  18. //! Given a MonadPlus `M`, the signature is
  19. //! @f$ \mathtt{empty}_M : \emptyset \to M(T) @f$.
  20. //!
  21. //! @tparam M
  22. //! The tag of the monadic structure to return. This must be
  23. //! a model of the MonadPlus concept.
  24. //!
  25. //!
  26. //! Example
  27. //! -------
  28. //! @include example/empty.cpp
  29. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  30. template <typename M>
  31. constexpr auto empty = []() {
  32. return tag-dispatched;
  33. };
  34. #else
  35. template <typename M, typename = void>
  36. struct empty_impl : empty_impl<M, when<true>> { };
  37. template <typename M>
  38. struct empty_t;
  39. template <typename M>
  40. constexpr empty_t<M> empty{};
  41. #endif
  42. BOOST_HANA_NAMESPACE_END
  43. #endif // !BOOST_HANA_FWD_EMPTY_HPP