Bug 87003 - Kill BOOST_FOREACH on master and use C++11s range-based for() loops instead
Summary: Kill BOOST_FOREACH on master and use C++11s range-based for() loops instead
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: Other All
: low trivial
Assignee: Nathan Yee
URL:
Whiteboard: target:4.5.0
Keywords: difficultyBeginner, easyHack, skillCpp, topicCleanup
Depends on:
Blocks:
 
Reported: 2014-12-04 13:31 UTC by Björn Michaelsen
Modified: 2016-02-18 16:37 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Björn Michaelsen 2014-12-04 13:31:36 UTC
Most uses of BOOST_FOREACH should be replacable with a simple C++11 range-based for() iteration. Since this is now allowed on master for LibreOffice 4.5, we should get rid of BOOST_FOREACH, which is essentially a hack/backport to the same effect. When doing so, please also take care to remove the include directive for boost/foreach.hpp with the last removed macro.

Here is an article describing ranged for:
http://www.cprogramming.com/c++11/c++11-ranged-for-loop.html
Comment 1 Robinson Tryon (qubit) 2014-12-04 15:22:27 UTC
Marking as enhancement
Status -> NEW
Comment 2 Stephan Bergmann 2014-12-05 08:57:14 UTC
(In reply to Björn Michaelsen from comment #0)
> Most uses of BOOST_FOREACH should be replacable with a simple C++11
> range-based for() iteration

...or for-each and a lambda (depending on what looks more "natural" in a given case)
Comment 3 Pieter Adriaensen 2014-12-20 15:18:08 UTC
Assigned it to myself
Comment 4 Nathan Yee 2015-01-01 00:19:17 UTC
I've been working on this bug since there seems to not have been activity on this bug for more than a week. It seems like converting to range-based for loops is fairly trivial except in this specific case shown here:

http://opengrok.libreoffice.org/xref/core/sw/source/core/doc/CntntIdxStore.cxx#271

Apparently range-based for loops cannot be used to iterate over an std::pair. Does anyone have any advice on how to resolve this issue? I have replaced all instances of BOOST_FOREACH in the project except for this one already.
Comment 5 David Tardon 2015-01-01 07:37:55 UTC
(In reply to Nathan Yee from comment #4)
> http://opengrok.libreoffice.org/xref/core/sw/source/core/doc/CntntIdxStore.
> cxx#271
> 
> Apparently range-based for loops cannot be used to iterate over an
> std::pair. Does anyone have any advice on how to resolve this issue?

Iterate over pRedlineTbl. That is what the current BOOST_FOREACH does, i.e., it iterates over a range defined by an std::pair of iterators.
Comment 6 Nathan Yee 2015-01-01 19:02:12 UTC
Sent a patch for this bug over gerrit at https://gerrit.libreoffice.org/13714. I'm going to assign this bug to myself for the time being.
Comment 7 Commit Notification 2015-01-05 09:35:21 UTC
Nathan Yee committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=a509a8d9951a0c31bea0f4ff8942720cad8b6e7f

Resolves: fdo#87003 Kill BOOST_FOREACH on master

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 8 Commit Notification 2015-01-07 14:58:13 UTC
Pieter Adriaensen committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f29bf4635958f7d4b8a22c0825cbcca4858ba037

Resolves: fdo#87003 - Kill BOOST_FOREACH

It will be available in 4.5.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 9 Robinson Tryon (qubit) 2015-12-15 23:58:31 UTC
Migrating Whiteboard tags to Keywords: (EasyHack DifficultyBeginner SkillCpp TopicCleanup)
[NinjaEdit]
Comment 10 Robinson Tryon (qubit) 2016-02-18 16:37:05 UTC
Remove LibreOffice Dev List from CC on EasyHacks
(curtailing excessive email to list)
[NinjaEdit]