rahul_1234's blog

By rahul_1234, history, 9 years ago, In English

Can someone explain me the macro:

#define tr(c,it) for( typeof(c.begin()) it=c.begin(); it!=c.end(); ++it )

Plz stress on use of typeof and why this macro can be used for all the containers.

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it +9 Vote: I do not like it

typeof is a non-standard extension. C++11 analog is decltype; but in C++11 this macro is most likely unnecessary because you can just write for (auto& elem : c).