Boost logo

Boost :

From: (noreply_at_[hidden])
Date: 2007-03-08 09:37:47

Bugs item #1676565, was opened at 2007-03-08 06:37
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: boost::format and operator priority rule

Initial Comment:
boost::format uses operator % to "feed" a string to a formatter, as in

cout<<format("Choose %1% of %2%") % 5 % 37; //writes "Choose 5 of 37"

This leads to a compile-time error when arithmetic operations are used without parenthesizing, e.g.

cout<<format("Choose %1% of %2%") % total-remaining+1 % total; //WRONG, tries to apply operator - to a formatter

because operator % has a higher priority than operator - .

This is indeed quite a common case; I suggest that operator % be replaced with an operator with lower priority, such as << . I can't figure out why operator % was chosen, is there a reason to use it?


--federico poloni


You can respond by visiting:

Take Surveys. Earn Cash. Influence the Future of IT
Join's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
Boost-bugs mailing list

Boost list run by bdawes at, gregod at, cpdaniel at, john at