]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/fwd/plus.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / fwd / plus.hpp
1 /*!
2 @file
3 Forward declares `boost::hana::plus`.
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_PLUS_HPP
11 #define BOOST_HANA_FWD_PLUS_HPP
12
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
15
16
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Associative binary operation on a `Monoid`.
19 //! @ingroup group-Monoid
20 //!
21 //! @param x, y
22 //! Two objects to combine with the `Monoid`'s binary operation.
23 //!
24 //!
25 //! Cross-type version of the method
26 //! --------------------------------
27 //! The `plus` method is "overloaded" to handle distinct data types
28 //! with certain properties. Specifically, `plus` 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 `Monoid`s when taken individually
33 //! 3. `to<C> : A -> B` and `to<C> : B -> C` are `Monoid`-embeddings, as
34 //! determined by the `is_embedding` metafunction.
35 //!
36 //! The definition of `plus` for data types satisfying the above
37 //! properties is obtained by setting
38 //! @code
39 //! plus(x, y) = plus(to<C>(x), to<C>(y))
40 //! @endcode
41 //!
42 //!
43 //! Example
44 //! -------
45 //! @include example/plus.cpp
46 #ifdef BOOST_HANA_DOXYGEN_INVOKED
47 constexpr auto plus = [](auto&& x, auto&& y) -> decltype(auto) {
48 return tag-dispatched;
49 };
50 #else
51 template <typename T, typename U, typename = void>
52 struct plus_impl : plus_impl<T, U, when<true>> { };
53
54 struct plus_t {
55 template <typename X, typename Y>
56 constexpr decltype(auto) operator()(X&& x, Y&& y) const;
57 };
58
59 constexpr plus_t plus{};
60 #endif
61 BOOST_HANA_NAMESPACE_END
62
63 #endif // !BOOST_HANA_FWD_PLUS_HPP