equivalence_class.hpp 996 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright Louis Dionne 2013-2017
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  4. #ifndef TEST_SUPPORT_EQUIVALENCE_CLASS_HPP
  5. #define TEST_SUPPORT_EQUIVALENCE_CLASS_HPP
  6. #include <boost/hana/fwd/equal.hpp>
  7. struct EquivalenceClass { };
  8. template <typename Token, typename T>
  9. struct equivalence_class_impl {
  10. Token equivalence_class;
  11. T unwrap;
  12. using hana_tag = EquivalenceClass;
  13. };
  14. template <typename Token, typename X>
  15. constexpr equivalence_class_impl<Token, X> equivalence_class(Token token, X x) {
  16. return {token, x};
  17. }
  18. namespace boost { namespace hana {
  19. template <>
  20. struct equal_impl<EquivalenceClass, EquivalenceClass> {
  21. template <typename X, typename Y>
  22. static constexpr auto apply(X x, Y y)
  23. { return hana::equal(x.equivalence_class, y.equivalence_class); }
  24. };
  25. }} // end namespace boost::hana
  26. #endif // !TEST_SUPPORT_EQUIVALENCE_CLASS_HPP