3 Forward declares `boost::hana::plus`.
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)
10 #ifndef BOOST_HANA_FWD_PLUS_HPP
11 #define BOOST_HANA_FWD_PLUS_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
17 BOOST_HANA_NAMESPACE_BEGIN
18 //! Associative binary operation on a `Monoid`.
19 //! @ingroup group-Monoid
22 //! Two objects to combine with the `Monoid`'s binary operation.
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.
36 //! The definition of `plus` for data types satisfying the above
37 //! properties is obtained by setting
39 //! plus(x, y) = plus(to<C>(x), to<C>(y))
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;
51 template <typename T, typename U, typename = void>
52 struct plus_impl : plus_impl<T, U, when<true>> { };
55 template <typename X, typename Y>
56 constexpr decltype(auto) operator()(X&& x, Y&& y) const;
59 constexpr plus_t plus{};
61 BOOST_HANA_NAMESPACE_END
63 #endif // !BOOST_HANA_FWD_PLUS_HPP