c++ primer statement about vectors containing vectors

Discussion in 'C++' started by pauldepstein@att.net, Mar 26, 2008.

  1. Guest

    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
    , Mar 26, 2008
    #1
    1. Advertising

  2. red floyd Guest

    wrote:
    > 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.
    red floyd, Mar 26, 2008
    #2
    1. Advertising

  3. asterisc Guest

    On Mar 26, 4:34 am, wrote:
    > 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.
    asterisc, Mar 26, 2008
    #3
  4. Shadowman Guest

    wrote:
    > 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

    --
    SM
    rot13 for email
    Shadowman, Mar 26, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand P Paralkar
    Replies:
    2
    Views:
    9,381
    Srinivasan Venkataramanan
    Aug 4, 2003
  2. Joakim Hove

    macro containing include statement

    Joakim Hove, Aug 18, 2004, in forum: C Programming
    Replies:
    10
    Views:
    1,090
    Capstar
    Aug 20, 2004
  3. Replies:
    5
    Views:
    320
  4. arnuld
    Replies:
    2
    Views:
    342
    Daniel T.
    Aug 16, 2007
  5. Guest
    Replies:
    0
    Views:
    438
    Guest
    Sep 14, 2005
Loading...

Share This Page