union.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*!
  2. @file
  3. Forward declares `boost::hana::union_`.
  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_UNION_HPP
  9. #define BOOST_HANA_FWD_UNION_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <boost/hana/core/when.hpp>
  12. BOOST_HANA_NAMESPACE_BEGIN
  13. //! Returns the union of two sets.
  14. //! @relates hana::set
  15. //!
  16. //! Given two sets `xs` and `ys`, `union_(xs, ys)` is a new set containing
  17. //! all the elements of `xs` and all the elements of `ys`, without
  18. //! duplicates. For any object `x`, the following holds:
  19. //! @code
  20. //! x ^in^ union_(xs, ys) if and only if x ^in^ xs || x ^in^ ys
  21. //! @endcode
  22. //!
  23. //!
  24. //! @param xs, ys
  25. //! Two sets to compute the union of.
  26. //!
  27. //!
  28. //! Example
  29. //! -------
  30. //! @include example/union.cpp
  31. //!
  32. //!
  33. //! Benchmarks
  34. //! ----------
  35. //! <div class="benchmark-chart"
  36. //! style="min-width: 310px; height: 400px; margin: 0 auto"
  37. //! data-dataset="benchmark.union.compile.json">
  38. //! </div>
  39. #ifdef BOOST_HANA_DOXYGEN_INVOKED
  40. constexpr auto union_ = [](auto&& xs, auto&& ys) {
  41. return tag-dispatched;
  42. };
  43. #else
  44. template <typename S, typename = void>
  45. struct union_impl : union_impl<S, when<true>> { };
  46. struct union_t {
  47. template <typename Xs, typename Ys>
  48. constexpr auto operator()(Xs&& xs, Ys&& ys) const;
  49. };
  50. constexpr union_t union_{};
  51. #endif
  52. BOOST_HANA_NAMESPACE_END
  53. #endif // !BOOST_HANA_FWD_UNION_HPP