1 /*! 2 @file 3 Forward declares `boost::hana::minus`. 4 5 @copyright Louis Dionne 2013-2017 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_MINUS_HPP 11 #define BOOST_HANA_FWD_MINUS_HPP 12 13 #include <boost/hana/config.hpp> 14 #include <boost/hana/core/when.hpp> 15 16 17 BOOST_HANA_NAMESPACE_BEGIN 18 //! Subtract two elements of a group. 19 //! @ingroup group-Group 20 //! 21 //! Specifically, this performs the `Monoid` operation on the first 22 //! argument and on the inverse of the second argument, thus being 23 //! equivalent to: 24 //! @code 25 //! minus(x, y) == plus(x, negate(y)) 26 //! @endcode 27 //! 28 //! 29 //! Cross-type version of the method 30 //! -------------------------------- 31 //! The `minus` method is "overloaded" to handle distinct data types 32 //! with certain properties. Specifically, `minus` is defined for 33 //! _distinct_ data types `A` and `B` such that 34 //! 1. `A` and `B` share a common data type `C`, as determined by the 35 //! `common` metafunction 36 //! 2. `A`, `B` and `C` are all `Group`s when taken individually 37 //! 3. `to<C> : A -> B` and `to<C> : B -> C` are `Group`-embeddings, as 38 //! determined by the `is_embedding` metafunction. 39 //! 40 //! The definition of `minus` for data types satisfying the above 41 //! properties is obtained by setting 42 //! @code 43 //! minus(x, y) = minus(to<C>(x), to<C>(y)) 44 //! @endcode 45 //! 46 //! 47 //! Example 48 //! ------- 49 //! @include example/minus.cpp 50 #ifdef BOOST_HANA_DOXYGEN_INVOKED 51 constexpr auto minus = [](auto&& x, auto&& y) -> decltype(auto) { 52 return tag-dispatched; 53 }; 54 #else 55 template <typename T, typename U, typename = void> 56 struct minus_impl : minus_impl<T, U, when<true>> { }; 57 58 struct minus_t { 59 template <typename X, typename Y> 60 constexpr decltype(auto) operator()(X&& x, Y&& y) const; 61 }; 62 63 constexpr minus_t minus{}; 64 #endif 65 BOOST_HANA_NAMESPACE_END 66 67 #endif // !BOOST_HANA_FWD_MINUS_HPP 68