[Boost-bugs] [ boost-Bugs-1676565 ] boost::format and operator priority rule

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: https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1676565&group_id=7586 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? Thanks, --federico poloni ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1676565&group_id=7586 ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Boost-bugs mailing list Boost-bugs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/boost-bugs
participants (1)
-
SourceForge.net