members.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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/concept/struct.hpp>
  6. #include <boost/hana/equal.hpp>
  7. #include <boost/hana/members.hpp>
  8. #include "minimal_struct.hpp"
  9. #include <laws/base.hpp>
  10. #include <support/seq.hpp>
  11. namespace hana = boost::hana;
  12. using hana::test::ct_eq;
  13. struct MoveOnly {
  14. MoveOnly() = default;
  15. MoveOnly(MoveOnly&&) = default;
  16. MoveOnly(MoveOnly const&) = delete;
  17. MoveOnly& operator=(MoveOnly&&) = default;
  18. MoveOnly& operator=(MoveOnly const&) = delete;
  19. };
  20. int main() {
  21. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  22. hana::members(obj()),
  23. ::seq()
  24. ));
  25. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  26. hana::members(obj(ct_eq<0>{})),
  27. ::seq(ct_eq<0>{})
  28. ));
  29. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  30. hana::members(obj(ct_eq<0>{}, ct_eq<1>{})),
  31. ::seq(ct_eq<0>{}, ct_eq<1>{})
  32. ));
  33. BOOST_HANA_CONSTANT_CHECK(hana::equal(
  34. hana::members(obj(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})),
  35. ::seq(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})
  36. ));
  37. // make sure it works with move only types
  38. auto z1 = hana::members(obj(MoveOnly{}));
  39. auto z2 = hana::members(obj(MoveOnly{}, MoveOnly{}));
  40. (void)z1;
  41. (void)z2;
  42. }