Why has vector<vector<int>> been *kept* illegal?

Why has vector<vector<int>> been *kept* illegal?

Post by pjp » Wed, 18 May 2005 01:21:02



The rationale stems from a basic principle of C++ (and C) parsing
known as the "maximum munch" rule. It says that the longest
sequence of characters that can make a valid token is always
the next token. Thus ">>" always wins out over ">" ">".

Having said that, I must report that the C++ committee seems to
have solved this annoying problem last month in Lillehammer. The
next revision of C++ will indeed accept "vector<vector<int>>"
with the meaning we all want.

P.J. Plauger
Dinkumware, Ltd.
http://www.yqcomputer.com/


---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.yqcomputer.com/ ]
 
 
 

1. Splitting vector<pair<int,int> > to pair<vector<int>,vector<int> >

2. Splitting vector<pair<int,int> > to pair<vector<int>,vector<int> >

What would be the most effective way to convert vector<pair<int,int> >
to pair<vector<int>,vector<int> >?

I know I can do it as follows:

struct split : unary_function<void, pair<int,int> >
{
pair<vector<int>,vector<int> > a;
void operator()(pair<int,int> p) { a.first.push_back(p.first);
a.second.push_back(p.second); }
};

...
vector<pair<int,int> > p;
for (int i = 0; i < 100; i++)
p.push_back(pair<int,int>(i,2*i));

split s = for_each(p.begin(), p.end(), split());
...

But I'm not very satisfied with that solution. It seems that I'll
need to have 3 vectors at the end of the day, 1 of the original, and 2
afterwards.

Is there a better way?

(fyi: I'm trying to write an app for audio data that will split the
interleaved stereo channels into seperate right and left channels.)

3. Initializing vector<vector<int> > and other vector questions...

4. Splitting vector<pair<int,int> > to pair<vector<int>,vector<int>

5. Splitting vector<pair<int,int> > to pair<vector<int>,vector<int>

6. Splitting vector<pair<int,int> > to pair<vector<int>,vector<int>

7. Seg fault!: passing vector<vector<int> > to a function

8. vector<int> and vector<bool>

9. declaration of size of vector<vector<int> >

10. template function (vector<int> vs. vector<gsl_vector*>)

11. Convert from std::vector<double> to std::vector<int>

12. undefined reference to `std::vector<int, std::allocator<int> >

13. comparing elements of vector<int> and list<int>

14. static_cast vector<float> to vector<double>

15. vector<vector<Point3D> >