deque.cpp 1008 B

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/ext/boost/fusion/deque.hpp>
  7. #include <boost/hana/integral_constant.hpp>
  8. #include <boost/hana/transform.hpp>
  9. #include <boost/fusion/include/deque.hpp>
  10. #include <boost/fusion/include/make_deque.hpp>
  11. #include <string>
  12. namespace fusion = boost::fusion;
  13. namespace hana = boost::hana;
  14. struct Fish { std::string name; };
  15. struct Cat { std::string name; };
  16. struct Dog { std::string name; };
  17. int main() {
  18. fusion::deque<Fish, Cat, Dog> animals{{"Nemo"}, {"Garfield"}, {"Snoopy"}};
  19. hana::front(animals).name = "Moby Dick";
  20. auto names = hana::transform(animals, [](auto a) {
  21. return a.name;
  22. });
  23. BOOST_HANA_RUNTIME_CHECK(hana::equal(
  24. names,
  25. fusion::make_deque("Moby Dick", "Garfield", "Snoopy")
  26. ));
  27. }