fork download
  1. #include <vector>
  2.  
  3. class SomeClass {
  4. public:
  5. // ...
  6. template <class InputIterator>
  7. int containerMethod(const InputIterator &begin, const InputIterator &end);
  8. // ...
  9. private:
  10. // ...
  11. };
  12.  
  13. template <class Iter> int SomeClass::containerMethod
  14. (const Iter &begin, const Iter&end) {
  15. // Here I need to instantiate an iterator for the container.
  16. Iter iter;
  17. for (iter = begin; iter != end; ++iter) {
  18. // This does not seem to work.
  19. }
  20. return 0;
  21. }
  22.  
  23. int main () {
  24. std::vector<int> v;
  25. SomeClass s;
  26. s.containerMethod(v.begin(), v.end());
  27. }
  28.  
Success #stdin #stdout 0.01s 2720KB
stdin
Standard input is empty
stdout
Standard output is empty