fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <list>
  4.  
  5. struct {
  6. template<class containerType>
  7. void operator() ( containerType& vec ) {
  8.  
  9. for (auto i = vec.begin(); i!=vec.end(); ++i) {
  10. std::cout << *i << ", ";
  11. }
  12.  
  13. std::cout << '\n';
  14.  
  15. }
  16. } bar;
  17.  
  18. template<typename funcType>
  19. void foo(funcType func) {
  20.  
  21. std::vector<int> vals = { 1, 2, 3 };
  22. func(vals);
  23.  
  24. }
  25.  
  26. int main() {
  27. foo( bar );
  28. }
  29.  
Success #stdin #stdout 0s 2960KB
stdin
Standard input is empty
stdout
1, 2, 3,