product.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 BOOST_HANA_TEST_LAWS_PRODUCT_HPP
  5. #define BOOST_HANA_TEST_LAWS_PRODUCT_HPP
  6. #include <boost/hana/assert.hpp>
  7. #include <boost/hana/concept/product.hpp>
  8. #include <boost/hana/core/make.hpp>
  9. #include <boost/hana/core/when.hpp>
  10. #include <boost/hana/equal.hpp>
  11. #include <boost/hana/first.hpp>
  12. #include <boost/hana/second.hpp>
  13. #include <laws/base.hpp>
  14. namespace boost { namespace hana { namespace test {
  15. template <typename P, typename = when<true>>
  16. struct TestProduct : TestProduct<P, laws> {
  17. using TestProduct<P, laws>::TestProduct;
  18. };
  19. template <typename P>
  20. struct TestProduct<P, laws> {
  21. template <typename Elements>
  22. TestProduct(Elements elements) {
  23. foreach2(elements, [](auto x, auto y) {
  24. static_assert(Product<decltype(hana::make<P>(x, y))>{}, "");
  25. BOOST_HANA_CHECK(hana::equal(
  26. hana::first(hana::make<P>(x, y)),
  27. x
  28. ));
  29. BOOST_HANA_CHECK(hana::equal(
  30. hana::second(hana::make<P>(x, y)),
  31. y
  32. ));
  33. });
  34. }
  35. };
  36. }}} // end namespace boost::hana::test
  37. #endif // !BOOST_HANA_TEST_LAWS_PRODUCT_HPP