one.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*!
  2. @file
  3. Forward declares `boost::hana::one`.
  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_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. constexpr decltype(auto) operator()() const;
  34. };
  35. template <typename R>
  36. constexpr one_t<R> one{};
  37. #endif
  38. BOOST_HANA_NAMESPACE_END
  39. #endif // !BOOST_HANA_FWD_ONE_HPP