c++ primer statement about vectors containing vectors

P

pauldepstein

C++ Primer by Lippman, Lajoie and Moo seems to object to code like
std::vector<std::vector<double>> something;

The concern is that >> will be interpreted as a shift operator and the
code will not compile. However, I have seen no problems with this
type of code and our company happily seems to accept code like the
above with no spaces between the two > characters.

Is the above code a real problem or not?

Thanks,

Paul Epstein
 
R

red floyd

C++ Primer by Lippman, Lajoie and Moo seems to object to code like
std::vector<std::vector<double>> something;

The concern is that >> will be interpreted as a shift operator and the
code will not compile. However, I have seen no problems with this
type of code and our company happily seems to accept code like the
above with no spaces between the two > characters.

Is the above code a real problem or not?

Yes, it is. Your particular compiler may add that feature as an
extension, and it's also slated for C++0x, but it is not standard
compliant code.
 
A

asterisc

C++ Primer by Lippman, Lajoie and Moo seems to object to code like
std::vector<std::vector<double>> something;

The concern is that >> will be interpreted as a shift operator and the
code will not compile. However, I have seen no problems with this
type of code and our company happily seems to accept code like the
above with no spaces between the two > characters.

Is the above code a real problem or not?

Thanks,

Paul Epstein

Can you post the chapter and page where did you find that? (among with
the edition of the book)

I read that book and I remember they specified that you *have* to
leave a white space between the two '>'. Maybe not in every
occurrence, but they did it at least when they wrote
std::vector<std::vector<double> > for the first time.
 
S

Shadowman

C++ Primer by Lippman, Lajoie and Moo seems to object to code like
std::vector<std::vector<double>> something;

The concern is that >> will be interpreted as a shift operator and the
code will not compile. However, I have seen no problems with this
type of code and our company happily seems to accept code like the
above with no spaces between the two > characters.

Is the above code a real problem or not?

As stated elsethread, it's illegal without the whitespace according to
the current standard, but that looks like it will change for the next
standard. Here's an interesting relevant article from the standards
committee:
http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1757.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top