Sunday, January 04, 2009

I tried to declare a vector that has another container in it. For example,vector<vector<int>> vecInt;

This syntax works within MS Visual C++, but not in GCC. In GCC, the compiler says`>>' should be `> >' within a nested template

The above error message is clear. We just need to insert space between angle brackets to fix the issue and change the above statement tovector< vector<int> > vectInt;

However,if the inner container is more complicated, the compiler error messagemay make you wonder what is happening. For example, if the innercontainer is Boost's dynamic bitset:vector<boost::dynamic_bitset<>> vecBsRoiData;

The error message will bevecBsRoiData' was not declared in this scopeTheerror message is very confusing, but can be handled in the same way byinserting space between angle brackets and change it tovector< boost::dynamic_bitset<> > vecBsRoiData;

Note: in reality, we only need to insert space to the closing bracket, but doing so may make the code looks strange. Therefore, I inserted space to both opening and closing brackets.