|
|
|||
File indexing completed on 2025-12-15 09:53:04
0001 /*! 0002 @file 0003 Forward declares `boost::hana::plus`. 0004 0005 Copyright Louis Dionne 2013-2022 0006 Distributed under the Boost Software License, Version 1.0. 0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) 0008 */ 0009 0010 #ifndef BOOST_HANA_FWD_PLUS_HPP 0011 #define BOOST_HANA_FWD_PLUS_HPP 0012 0013 #include <boost/hana/config.hpp> 0014 #include <boost/hana/core/when.hpp> 0015 0016 0017 namespace boost { namespace hana { 0018 //! Associative binary operation on a `Monoid`. 0019 //! @ingroup group-Monoid 0020 //! 0021 //! @param x, y 0022 //! Two objects to combine with the `Monoid`'s binary operation. 0023 //! 0024 //! 0025 //! Cross-type version of the method 0026 //! -------------------------------- 0027 //! The `plus` method is "overloaded" to handle distinct data types 0028 //! with certain properties. Specifically, `plus` is defined for 0029 //! _distinct_ data types `A` and `B` such that 0030 //! 1. `A` and `B` share a common data type `C`, as determined by the 0031 //! `common` metafunction 0032 //! 2. `A`, `B` and `C` are all `Monoid`s when taken individually 0033 //! 3. `to<C> : A -> B` and `to<C> : B -> C` are `Monoid`-embeddings, as 0034 //! determined by the `is_embedding` metafunction. 0035 //! 0036 //! The definition of `plus` for data types satisfying the above 0037 //! properties is obtained by setting 0038 //! @code 0039 //! plus(x, y) = plus(to<C>(x), to<C>(y)) 0040 //! @endcode 0041 //! 0042 //! 0043 //! Example 0044 //! ------- 0045 //! @include example/plus.cpp 0046 #ifdef BOOST_HANA_DOXYGEN_INVOKED 0047 constexpr auto plus = [](auto&& x, auto&& y) -> decltype(auto) { 0048 return tag-dispatched; 0049 }; 0050 #else 0051 template <typename T, typename U, typename = void> 0052 struct plus_impl : plus_impl<T, U, when<true>> { }; 0053 0054 struct plus_t { 0055 template <typename X, typename Y> 0056 constexpr decltype(auto) operator()(X&& x, Y&& y) const; 0057 }; 0058 0059 BOOST_HANA_INLINE_VARIABLE constexpr plus_t plus{}; 0060 #endif 0061 }} // end namespace boost::hana 0062 0063 #endif // !BOOST_HANA_FWD_PLUS_HPP
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|