difference.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*!
  2. @file
  3. Forward declares `boost::hana::difference`.
  4. @copyright Louis Dionne 2013-2016
  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_DIFFERENCE_HPP
  9. #define BOOST_HANA_FWD_DIFFERENCE_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Returns the set-theoretic difference of two sets.
  14. //! @relates hana::set
  15. //!
  16. //! Given two sets `xs` and `ys`, `difference(xs, ys)` is a new set
  17. //! containing all the elements of `xs` that are _not_ contained in `ys`.
  18. //! For any object `x`, the following holds:
  19. //! @code
  20. //! x ^in^ difference(xs, ys) if and only if x ^in^ xs && !(x ^in^ ys)
  21. //! @endcode
  22. //!
  23. //!
  24. //! @note
  25. //! This operation is not commutative, i.e. `difference(xs, ys)` is not
  26. //! necessarily the same as `difference(ys, xs)`. Indeed, consider the
  27. //! case where `xs` is empty and `ys` isn't. Then, `difference(xs, ys)`
  28. //! is empty but `difference(ys, xs)` is equal to `ys`. For the symmetric
  29. //! version of this operation, see `symmetric_difference`.
  30. //!
  31. //!
  32. //! @param xs
  33. //! A set to remove values from.
  34. //!
  35. //! @param ys
  36. //! The set whose values are removed from `xs`.
  37. //!
  38. //!
  39. //! Example
  40. //! -------
  41. //! @include example/difference.cpp
  42. //!
  43. //!
  44. //! Benchmarks
  45. //! ----------
  46. //! <div class="benchmark-chart"
  47. //! style="min-width: 310px; height: 400px; margin: 0 auto"
  48. //! data-dataset="benchmark.difference.compile.json">
  49. //! </div>
  50. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  51. constexpr auto difference = [](auto&& xs, auto&& ys) {
  52. return tag-dispatched;
  53. };
  54. #else
  55. template <typename S, typename = void>
  56. struct difference_impl : difference_impl<S, when<true>> { };
  57. struct difference_t {
  58. template <typename Xs, typename Ys>
  59. constexpr auto operator()(Xs&& xs, Ys&& ys) const;
  60. };
  61. constexpr difference_t difference{};
  62. #endif
  63. BOOST_HANA_NAMESPACE_END
  64. #endif // !BOOST_HANA_FWD_DIFFERENCE_HPP