minus.hpp 2.1 KB

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