mult.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*!
  2. @file
  3. Forward declares `boost::hana::mult`.
  4. Copyright Louis Dionne 2013-2022
  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_MULT_HPP
  9. #define BOOST_HANA_FWD_MULT_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. namespace boost { namespace hana {
  13. //! Associative operation of a `Ring`.
  14. //! @ingroup group-Ring
  15. //!
  16. //! @param x, y
  17. //! Two `Ring` elements to combine with the `Ring` binary operation.
  18. //!
  19. //!
  20. //! Cross-type version of the method
  21. //! --------------------------------
  22. //! The `mult` method is "overloaded" to handle distinct data types
  23. //! with certain properties. Specifically, `mult` is defined for
  24. //! _distinct_ data types `A` and `B` such that
  25. //! 1. `A` and `B` share a common data type `C`, as determined by the
  26. //! `common` metafunction
  27. //! 2. `A`, `B` and `C` are all `Ring`s when taken individually
  28. //! 3. `to<C> : A -> B` and `to<C> : B -> C` are `Ring`-embeddings, as
  29. //! determined by the `is_embedding` metafunction.
  30. //!
  31. //! The definition of `mult` for data types satisfying the above
  32. //! properties is obtained by setting
  33. //! @code
  34. //! mult(x, y) = mult(to<C>(x), to<C>(y))
  35. //! @endcode
  36. //!
  37. //!
  38. //! Example
  39. //! -------
  40. //! @include example/mult.cpp
  41. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  42. constexpr auto mult = [](auto&& x, auto&& y) -> decltype(auto) {
  43. return tag-dispatched;
  44. };
  45. #else
  46. template <typename T, typename U, typename = void>
  47. struct mult_impl : mult_impl<T, U, when<true>> { };
  48. struct mult_t {
  49. template <typename X, typename Y>
  50. constexpr decltype(auto) operator()(X&& x, Y&& y) const;
  51. };
  52. BOOST_HANA_INLINE_VARIABLE constexpr mult_t mult{};
  53. #endif
  54. }} // end namespace boost::hana
  55. #endif // !BOOST_HANA_FWD_MULT_HPP