fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <tuple>
  4. #include <boost/fusion/include/for_each.hpp>
  5. #include <boost/fusion/adapted/std_tuple.hpp>
  6.  
  7. struct op
  8. {
  9. void operator()(int x) const
  10. {
  11. std::cout << "int " << x << std::endl;
  12. }
  13. void operator()(char x) const
  14. {
  15. std::cout << "'" << x << "'" << std::endl;
  16. }
  17. void operator()(const std::string &x) const
  18. {
  19. std::cout << "\"" << x << "\"" << std::endl;
  20. }
  21. };
  22.  
  23. int main()
  24. {
  25. std::tuple<int, char, std::string> v(1, 'a', "Hello");
  26. boost::fusion::for_each(v, op());
  27. }
  28.  
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
int 1
'a'
"Hello"