// Copyright Louis Dionne 2013-2017 // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) #ifndef BOOST_HANA_TEST_LAWS_GROUP_HPP #define BOOST_HANA_TEST_LAWS_GROUP_HPP #include #include #include #include #include #include #include namespace boost { namespace hana { namespace test { template > struct TestGroup : TestGroup { using TestGroup::TestGroup; }; template struct TestGroup { template TestGroup(Xs xs) { hana::for_each(xs, [](auto x) { static_assert(Group{}, ""); }); #ifdef BOOST_HANA_WORKAROUND_MSVC_DECLTYPEAUTO_RETURNTYPE_662735 zero(); // force adding zero's member function to pending temploid list #endif foreach2(xs, [](auto x, auto y) { // left inverse BOOST_HANA_CHECK(hana::equal( hana::plus(x, hana::negate(x)), zero() )); // right inverse BOOST_HANA_CHECK(hana::equal( hana::plus(hana::negate(x), x), zero() )); // default definition of minus BOOST_HANA_CHECK(hana::equal( hana::minus(x, y), hana::plus(x, hana::negate(y)) )); BOOST_HANA_CHECK(hana::equal( hana::minus(y, x), hana::plus(y, hana::negate(x)) )); // default definition of negate BOOST_HANA_CHECK(hana::equal( hana::negate(hana::negate(x)), x )); }); } }; template struct TestGroup::value>> : TestGroup { template TestGroup(Xs xs) : TestGroup{xs} { foreach2(xs, [](auto x, auto y) { BOOST_HANA_CHECK(hana::equal( hana::negate(hana::value(x)), hana::value(hana::negate(x)) )); BOOST_HANA_CHECK(hana::equal( hana::minus(hana::value(x), hana::value(y)), hana::value(hana::minus(x, y)) )); }); } }; }}} // end namespace boost::hana::test #endif // !BOOST_HANA_TEST_LAWS_GROUP_HPP