empty.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*!
  2. @file
  3. Forward declares `boost::hana::empty`.
  4. @copyright Louis Dionne 2013-2017
  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. constexpr auto operator()() const;
  40. };
  41. template <typename M>
  42. constexpr empty_t<M> empty{};
  43. #endif
  44. BOOST_HANA_NAMESPACE_END
  45. #endif // !BOOST_HANA_FWD_EMPTY_HPP