Boost logo

Boost Users :

Subject: Re: [Boost-users] still stuck on expectation points
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2010-04-16 21:16:13


On Fri, Apr 16, 2010 at 6:34 PM, philip tucker <phhht_at_[hidden]> wrote:
> This
>
> start %= (constitkind > id > ':' > id >> probs) % ","; // FAILS
>
> Should read
>
> start %= (constitkind >> id > ':' > id >> probs) % ","; // FAILS
>
> Sorry.

Because of how operator precedence works in C++. You should pretty
well memorize the C++ precedence rules before starting to use more
advanced C++ features that rely on fancy operator usage, else run into
a lot of 'fun' things like this. Basically this:
    start %= (constitkind >> id > ':' > id >> probs) % ",";
Is read as this to the C++ parser:
    start %= (constitkind >> (id > ':' > id) >> probs) % ",";
Because greater-then's have a different precedence level then right-shifts.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net