intersection.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*!
  2. @file
  3. Defines `boost::hana::intersection`.
  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_INTERSECTION_HPP
  9. #define BOOST_HANA_INTERSECTION_HPP
  10. #include <boost/hana/fwd/intersection.hpp>
  11. #include <boost/hana/config.hpp>
  12. #include <boost/hana/core/dispatch.hpp>
  13. BOOST_HANA_NAMESPACE_BEGIN
  14. //! @cond
  15. template <typename Xs, typename Ys>
  16. constexpr auto intersection_t::operator()(Xs&& xs, Ys&& ys) const {
  17. using S = typename hana::tag_of<Xs>::type;
  18. using Intersection = BOOST_HANA_DISPATCH_IF(intersection_impl<S>,
  19. true
  20. );
  21. return Intersection::apply(static_cast<Xs&&>(xs), static_cast<Ys&&>(ys));
  22. }
  23. //! @endcond
  24. template <typename S, bool condition>
  25. struct intersection_impl<S, when<condition>> : default_ {
  26. template <typename ...Args>
  27. static constexpr auto apply(Args&& ...) = delete;
  28. };
  29. BOOST_HANA_NAMESPACE_END
  30. #endif // !BOOST_HANA_INTERSECTION_HPP