fusion_to_hana.cpp 824 B

12345678910111213141516171819202122232425262728293031
  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/for_each.hpp>
  5. #include <boost/hana/tuple.hpp>
  6. #include <boost/hana/ext/boost/fusion/vector.hpp>
  7. #include <boost/fusion/include/vector.hpp>
  8. #include <iostream>
  9. namespace fusion = boost::fusion;
  10. namespace hana = boost::hana;
  11. //! [main]
  12. // In the old code, this used to receive a Fusion sequence.
  13. // Now, it can be either a Hana sequence or a Fusion sequence.
  14. template <typename Sequence>
  15. void f(Sequence const& seq) {
  16. hana::for_each(seq, [](auto const& element) {
  17. std::cout << element << std::endl;
  18. });
  19. }
  20. //! [main]
  21. int main() {
  22. f(hana::make_tuple(1, 2, 3));
  23. f(fusion::make_vector(1, 2, 3));
  24. }