tuple.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/experimental/printable.hpp>
  6. #include <boost/hana/tuple.hpp>
  7. #include <sstream>
  8. #include <string>
  9. namespace hana = boost::hana;
  10. int main() {
  11. {
  12. std::ostringstream ss;
  13. ss << hana::experimental::print(hana::make_tuple());
  14. BOOST_HANA_RUNTIME_CHECK(ss.str() == "()");
  15. }
  16. {
  17. std::ostringstream ss;
  18. ss << hana::experimental::print(hana::make_tuple(1));
  19. BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1)");
  20. }
  21. {
  22. std::ostringstream ss;
  23. ss << hana::experimental::print(hana::make_tuple(1, 2));
  24. BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2)");
  25. }
  26. {
  27. std::ostringstream ss;
  28. ss << hana::experimental::print(hana::make_tuple(1, '2', "3456"));
  29. BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2, 3456)");
  30. }
  31. {
  32. std::ostringstream ss;
  33. ss << hana::experimental::print(hana::make_tuple(1, '2', hana::make_tuple()));
  34. BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2, ())");
  35. }
  36. {
  37. std::ostringstream ss;
  38. ss << hana::experimental::print(hana::make_tuple(1, '2', hana::make_tuple(3.3, '4')));
  39. BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2, (3.3, 4))");
  40. }
  41. }