operator_arrow.cpp 884 B

12345678910111213141516171819202122232425262728293031323334353637
  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/optional.hpp>
  7. #include <laws/base.hpp>
  8. namespace hana = boost::hana;
  9. using hana::test::ct_eq;
  10. struct object {
  11. ct_eq<3> member;
  12. };
  13. int main() {
  14. auto lvalue = hana::just(object{});
  15. ct_eq<3>& ref = lvalue->member;
  16. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  17. ref,
  18. ct_eq<3>{}
  19. ));
  20. auto const const_lvalue = hana::just(object{});
  21. ct_eq<3> const& const_ref = const_lvalue->member;
  22. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  23. const_ref,
  24. ct_eq<3>{}
  25. ));
  26. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  27. hana::just(object{})->member,
  28. ct_eq<3>{}
  29. ));
  30. }