9
3

difference.hpp 1.1 KB

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