keys.cpp 781 B

1234567891011121314151617181920212223242526272829
  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/define_struct.hpp>
  6. #include <boost/hana/equal.hpp>
  7. #include <boost/hana/keys.hpp>
  8. #include <boost/hana/string.hpp>
  9. #include <boost/hana/tuple.hpp>
  10. #include <string>
  11. namespace hana = boost::hana;
  12. struct Person {
  13. BOOST_HANA_DEFINE_STRUCT(Person,
  14. (std::string, name),
  15. (unsigned short, age)
  16. );
  17. };
  18. int main() {
  19. Person john{"John", 30};
  20. BOOST_HANA_CONSTANT_CHECK(
  21. hana::keys(john) == hana::make_tuple(BOOST_HANA_STRING("name"),
  22. BOOST_HANA_STRING("age"))
  23. );
  24. }