functor.cpp 669 B

1234567891011121314151617181920212223242526
  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/transform.hpp>
  7. #include <boost/hana/tuple.hpp>
  8. #include <sstream>
  9. #include <string>
  10. namespace hana = boost::hana;
  11. auto to_string = [](auto x) {
  12. std::ostringstream ss;
  13. ss << x;
  14. return ss.str();
  15. };
  16. int main() {
  17. BOOST_HANA_RUNTIME_CHECK(
  18. hana::transform(hana::make_tuple(1, '2', "345", std::string{"67"}), to_string) ==
  19. hana::make_tuple("1", "2", "345", "67")
  20. );
  21. }