equal.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  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. #include <boost/hana/assert.hpp>
  5. #include <boost/hana/equal.hpp>
  6. #include <boost/hana/not.hpp>
  7. #include <boost/hana/not_equal.hpp> // for operator !=
  8. #include <boost/hana/type.hpp>
  9. namespace hana = boost::hana;
  10. struct T;
  11. struct U;
  12. int main() {
  13. BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::type_c<T>, hana::type_c<T>));
  14. BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(hana::type_c<T>, hana::type_c<U>)));
  15. BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(hana::type_c<void>, hana::type_c<U>)));
  16. BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(hana::type_c<T>, hana::type_c<void>)));
  17. BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::type_c<void>, hana::type_c<void>));
  18. BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::type_c<T&>, hana::type_c<T&>));
  19. BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(hana::type_c<T&>, hana::type_c<T&&>)));
  20. BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(hana::type_c<T const>, hana::type_c<T>)));
  21. BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::type_c<T const>, hana::type_c<T const>));
  22. // make sure we don't read from a non-constexpr variable in hana::equal
  23. auto t = hana::type_c<T>;
  24. static_assert(hana::equal(t, hana::type_c<T>), "");
  25. // check operators
  26. BOOST_HANA_CONSTANT_CHECK(hana::type_c<T> == hana::type_c<T>);
  27. BOOST_HANA_CONSTANT_CHECK(hana::type_c<T> != hana::type_c<U>);
  28. }