one.hpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*!
  2. @file
  3. Forward declares `boost::hana::one`.
  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_ONE_HPP
  9. #define BOOST_HANA_FWD_ONE_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Identity of the `Ring` multiplication.
  14. //! @ingroup group-Ring
  15. //!
  16. //! @tparam R
  17. //! The tag (must be a model of `Ring`) of the returned identity.
  18. //!
  19. //!
  20. //! Example
  21. //! -------
  22. //! @include example/one.cpp
  23. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  24. template <typename R>
  25. constexpr auto one = []() -> decltype(auto) {
  26. return tag-dispatched;
  27. };
  28. #else
  29. template <typename R, typename = void>
  30. struct one_impl : one_impl<R, when<true>> { };
  31. template <typename R>
  32. struct one_t;
  33. template <typename R>
  34. constexpr one_t<R> one{};
  35. #endif
  36. BOOST_HANA_NAMESPACE_END
  37. #endif // !BOOST_HANA_FWD_ONE_HPP