clear.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #include <boost/detail/lightweight_test.hpp>
  7. #include <boost/fusion/container/vector/vector.hpp>
  8. #include <boost/fusion/sequence/io/out.hpp>
  9. #include <boost/fusion/sequence/comparison/equal_to.hpp>
  10. #include <boost/fusion/container/generation/make_vector.hpp>
  11. #include <boost/fusion/algorithm/transformation/clear.hpp>
  12. #include <boost/mpl/vector_c.hpp>
  13. int
  14. main()
  15. {
  16. using namespace boost::fusion;
  17. std::cout << tuple_open('[');
  18. std::cout << tuple_close(']');
  19. std::cout << tuple_delimiter(", ");
  20. /// Testing pop_back
  21. {
  22. char const* s = "Ruby";
  23. typedef vector<int, char, double, char const*> vector_type;
  24. vector_type t1(1, 'x', 3.3, s);
  25. {
  26. std::cout << clear(t1) << std::endl;
  27. BOOST_TEST((clear(t1) == make_vector()));
  28. }
  29. }
  30. {
  31. typedef boost::mpl::vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
  32. std::cout << boost::fusion::clear(mpl_vec()) << std::endl;
  33. BOOST_TEST((boost::fusion::clear(mpl_vec()) == make_vector()));
  34. }
  35. return boost::report_errors();
  36. }