]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Forward declares `boost::hana::mult`. | |
4 | ||
5 | @copyright Louis Dionne 2013-2016 | |
6 | Distributed under the Boost Software License, Version 1.0. | |
7 | (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) | |
8 | */ | |
9 | ||
10 | #ifndef BOOST_HANA_FWD_MULT_HPP | |
11 | #define BOOST_HANA_FWD_MULT_HPP | |
12 | ||
13 | #include <boost/hana/config.hpp> | |
14 | #include <boost/hana/core/when.hpp> | |
15 | ||
16 | ||
17 | BOOST_HANA_NAMESPACE_BEGIN | |
18 | //! Associative operation of a `Ring`. | |
19 | //! @ingroup group-Ring | |
20 | //! | |
21 | //! @param x, y | |
22 | //! Two `Ring` elements to combine with the `Ring` binary operation. | |
23 | //! | |
24 | //! | |
25 | //! Cross-type version of the method | |
26 | //! -------------------------------- | |
27 | //! The `mult` method is "overloaded" to handle distinct data types | |
28 | //! with certain properties. Specifically, `mult` is defined for | |
29 | //! _distinct_ data types `A` and `B` such that | |
30 | //! 1. `A` and `B` share a common data type `C`, as determined by the | |
31 | //! `common` metafunction | |
32 | //! 2. `A`, `B` and `C` are all `Ring`s when taken individually | |
33 | //! 3. `to<C> : A -> B` and `to<C> : B -> C` are `Ring`-embeddings, as | |
34 | //! determined by the `is_embedding` metafunction. | |
35 | //! | |
36 | //! The definition of `mult` for data types satisfying the above | |
37 | //! properties is obtained by setting | |
38 | //! @code | |
39 | //! mult(x, y) = mult(to<C>(x), to<C>(y)) | |
40 | //! @endcode | |
41 | //! | |
42 | //! | |
43 | //! Example | |
44 | //! ------- | |
45 | //! @include example/mult.cpp | |
46 | #ifdef BOOST_HANA_DOXYGEN_INVOKED | |
47 | constexpr auto mult = [](auto&& x, auto&& y) -> decltype(auto) { | |
48 | return tag-dispatched; | |
49 | }; | |
50 | #else | |
51 | template <typename T, typename U, typename = void> | |
52 | struct mult_impl : mult_impl<T, U, when<true>> { }; | |
53 | ||
54 | struct mult_t { | |
55 | template <typename X, typename Y> | |
56 | constexpr decltype(auto) operator()(X&& x, Y&& y) const; | |
57 | }; | |
58 | ||
59 | constexpr mult_t mult{}; | |
60 | #endif | |
61 | BOOST_HANA_NAMESPACE_END | |
62 | ||
63 | #endif // !BOOST_HANA_FWD_MULT_HPP |