fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. template< class T >
  6. void foo( const char * v, T ) {
  7. cout << v << ": " <<__PRETTY_FUNCTION__ << endl;
  8. }
  9.  
  10. int main() {
  11. std::vector< int > array;
  12. array.push_back( 42 );
  13.  
  14. for (auto it : array) {
  15. foo( "#1", it );
  16. }
  17. for (auto& it : array) {
  18. foo( "#2", it );
  19. }
  20. for (const auto it : array) {
  21. foo( "#3", it );
  22. }
  23. for (const int & it : array) {
  24. foo( "#4", it );
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
#1: void foo(const char*, T) [with T = int]
#2: void foo(const char*, T) [with T = int]
#3: void foo(const char*, T) [with T = int]
#4: void foo(const char*, T) [with T = int]