Maximal Munch
Beginners in C++ template programming commonly end up writing following kind of code, which is not understood by compilers.
// Following gives compilation errors: std::vector<std::vector<int>> // Corrected code – observe space betwen two consecutive “>”s. std::vector<std::vector<int> > |
Due to “maximal munch” rule of compiler, the token “>>” is read as right-shift operator. Therefore, in nested templates in above example “>>” is not parsed as desired by the programmer. As a solution, programmer need to put a space between two consecutive “>”s.
Maximal Munch
Reviewed by Sourabh Soni
on
Sunday, January 31, 2010
Rating:
No comments