zero.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*!
  2. @file
  3. Forward declares `boost::hana::zero`.
  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_ZERO_HPP
  9. #define BOOST_HANA_FWD_ZERO_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Identity of `plus`.
  14. //! @ingroup group-Monoid
  15. //!
  16. //! @tparam M
  17. //! The tag (a `Monoid`) of the returned identity.
  18. //!
  19. //!
  20. //! Example
  21. //! -------
  22. //! @include example/zero.cpp
  23. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  24. template <typename M>
  25. constexpr auto zero = []() -> decltype(auto) {
  26. return tag-dispatched;
  27. };
  28. #else
  29. template <typename M, typename = void>
  30. struct zero_impl : zero_impl<M, when<true>> { };
  31. template <typename M>
  32. struct zero_t {
  33. constexpr decltype(auto) operator()() const;
  34. };
  35. template <typename M>
  36. constexpr zero_t<M> zero{};
  37. #endif
  38. BOOST_HANA_NAMESPACE_END
  39. #endif // !BOOST_HANA_FWD_ZERO_HPP