Boost C++ Libraries: Ticket #6131: #define foreach BOOST_FOREACH causes weird compile error in certain circumstances with boost 1.48 https://svn.boost.org/trac10/ticket/6131 <p> #define foreach BOOST_FOREACH causes compile error "'boost::BOOST_FOREACH' has not been declared" on its line if it appears after #include &lt;boost/foreach.hpp&gt; and before certain other boost headers. </p> <p> Compiler version: gcc (Gentoo 4.5.3-<a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">r1</a> p1.0, pie-0.4.5) 4.5.3 Also tried gcc 4.3.5, 4.4.6 and 4.6.2 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6131 Trac 1.4.3 loonycyborg Thu, 17 Nov 2011 14:17:22 GMT attachment set https://svn.boost.org/trac10/ticket/6131 https://svn.boost.org/trac10/ticket/6131 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">foreachtest.cpp</span> </li> </ul> <p> Test case. </p> Ticket Michel Morin <mimomorin@…> Fri, 18 Nov 2011 01:32:27 GMT <link>https://svn.boost.org/trac10/ticket/6131#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:1</guid> <description> <blockquote class="citation"> <p> before certain other boost headers. </p> </blockquote> <p> Specifically, those Boost headers are </p> <ul><li><code>boost/multi_index/hashed_index.hpp</code> </li><li><code>boost/multi_index/ordered_index.hpp</code> </li><li><code>boost/multi_index/random_access_index.hpp</code> </li><li><code>boost/multi_index/sequenced_index.hpp</code> </li></ul><p> and headers that eventually include them, right? </p> <p> Here are related threads in Boost-users ML: </p> <ul><li><a class="ext-link" href="http://thread.gmane.org/gmane.comp.lib.boost.user/71393"><span class="icon">​</span>[multi-index] foreach supports breaks compilation</a> </li><li><a class="ext-link" href="http://thread.gmane.org/gmane.comp.lib.boost.user/71410"><span class="icon">​</span>[foreach] #define foreach BOOST_FOREACH</a> </li></ul> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Fri, 18 Nov 2011 04:38:27 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:2</guid> <description> <p> Attempted a workaround on trunk here: &lt;<a class="ext-link" href="https://svn.boost.org/trac/boost/changeset/75540"><span class="icon">​</span>https://svn.boost.org/trac/boost/changeset/75540</a>&gt;. I'll merge to release if the tests don't explode. I don't see why they would. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Wed, 23 Nov 2011 04:59:35 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6131#comment:3 https://svn.boost.org/trac10/ticket/6131#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/75634" title="merge [75540] from trunk, fixes #6131">[75634]</a>) merge <a class="changeset" href="https://svn.boost.org/trac10/changeset/75540" title="attempting to address #6131">[75540]</a> from trunk, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6131" title="#6131: Bugs: #define foreach BOOST_FOREACH causes weird compile error in certain ... (closed: fixed)">#6131</a> </p> Ticket anonymous Mon, 05 Mar 2012 13:33:30 GMT status, version changed; resolution deleted https://svn.boost.org/trac10/ticket/6131#comment:4 https://svn.boost.org/trac10/ticket/6131#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.48.0</span> → <span class="trac-field-new">Boost 1.49.0</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> I use just this #define in my code and I have actually _started_ to get compiler error with boost 1.49 (Xcode 4.3, LLVM compiler 3.1): </p> <p> Redefinition of 'is_lightweight_proxy' Redefinition of 'is_noncopyable' </p> <p> And even more errors that say: </p> <p> No matching function for call to 'should_copy_impl' </p> Ticket anonymous Mon, 05 Mar 2012 13:37:01 GMT <link>https://svn.boost.org/trac10/ticket/6131#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6131#comment:4" title="Comment 4">anonymous</a>: </p> <blockquote class="citation"> <p> I use just this #define in my code and I have actually _started_ to get compiler error with boost 1.49 (Xcode 4.3, LLVM compiler 3.1): </p> <p> Redefinition of 'is_lightweight_proxy' Redefinition of 'is_noncopyable' </p> <p> And even more errors that say: </p> <p> No matching function for call to 'should_copy_impl' </p> </blockquote> <p> FWIW the error actually comes up when using BOOST_REVERSE_FOREACH (which I use alongside foreach): </p> <p> <a class="missing wiki">../Game/Widgets</a>.hpp:130:9: error: no matching function for call to 'should_copy_impl' </p> <blockquote> <p> PASS_TOUCH(touchBegan) <sup><del></del><del></del><del></del><del></del><del></del>~ </sup></p> </blockquote> <p> <a class="missing wiki">../Game/Widgets</a>.hpp:124:17: note: expanded from macro 'PASS_TOUCH' </p> <blockquote> <p> BOOST_REVERSE_FOREACH (const <a class="missing wiki">WidgetPtr</a>&amp; child, children) \ <sup> </sup></p> </blockquote> <p> /usr/local/include/boost/foreach.hpp:1117:77: note: expanded from macro 'BOOST_REVERSE_FOREACH' </p> <blockquote> <p> if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_end) = BOOST_FOREACH_REND(COL)) {} else \ </p> <blockquote> <p> <sup> </sup></p> </blockquote> </blockquote> <p> /usr/local/include/boost/foreach.hpp:1051:9: note: expanded from macro 'BOOST_FOREACH_REND' </p> <blockquote> <p> , BOOST_FOREACH_SHOULD_COPY(COL)) </p> <blockquote> <p> <sup> </sup></p> </blockquote> </blockquote> <p> /usr/local/include/boost/foreach.hpp:961:6: note: expanded from macro 'BOOST_FOREACH_SHOULD_COPY' </p> <blockquote> <p> (boost::foreach_detail_::should_copy_impl( \ </p> <blockquote> <p> <sup><del></del><del></del><del></del><del></del><del></del><del></del><del></del><del></del><del></del><del>~ </del></sup></p> </blockquote> </blockquote> <p> So maybe this is actually another bug? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Mon, 05 Mar 2012 17:18:09 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:6</guid> <description> <p> It's impossible to say without looking at a repro. Can you attach code that demonstrates the problem? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Mon, 19 Mar 2012 22:05:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:7</guid> <description> <p> In light of <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6455" title="#6455: Feature Requests: Boost foreach conflicts with Q_FOREACH and moc generation. (closed: fixed)">#6455</a>, it seems this "fix" is doing more harm than good. I've reverted foreach to the 1.47 version on trunk and plan to close this bug "won't fix". Sorry, I tried. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Tue, 27 Mar 2012 19:28:34 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6131#comment:8 https://svn.boost.org/trac10/ticket/6131#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/77591" title="merge [77416] from trunk, fixes #6131, fixes #6455">[77591]</a>) merge <a class="changeset" href="https://svn.boost.org/trac10/changeset/77416" title="reverting [75540] which seemed to make things worse">[77416]</a> from trunk, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6131" title="#6131: Bugs: #define foreach BOOST_FOREACH causes weird compile error in certain ... (closed: fixed)">#6131</a>, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6455" title="#6455: Feature Requests: Boost foreach conflicts with Q_FOREACH and moc generation. (closed: fixed)">#6455</a> </p> Ticket anonymous Tue, 05 Jun 2012 22:07:13 GMT <link>https://svn.boost.org/trac10/ticket/6131#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:9</guid> <description> <p> In 1.49 under Visual Studio 2008, I am now getting this error whenever I DON'T include &lt;boost/foreach.hpp&gt; until AFTER I #define foreach BOOST_FOREACH: </p> <p> 'boost::BOOST_FOREACH::is lightweight proxy' : class template has already been defined </p> <blockquote> <p> foreach_fwd.hpp(62) : see declaration of 'boost::BOOST_FOREACH::is_lightweight_proxy' </p> </blockquote> <p> Simple test that fails: </p> <p> #define foreach BOOST_FOREACH #include &lt;boost/foreach.hpp&gt; </p> <p> It works fine in the other order, i.e., the include before the #define. This never used to be a problem. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Tue, 05 Jun 2012 22:16:29 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:10</guid> <description> <p> Foreach was broken in 1.49. As you can see from the comment above, the change was reverted and the fix has already been migrated to the release branch. In 1.50 (currently in beta), the problem should be fixed. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 03 Jul 2012 19:45:02 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:11</guid> <description> <p> The problem still occur in 1.50.0. I stumbled on it while building mkvtoolnix 5.0.1 using clang 3.1 from Xcode 4.3.3. The patches from changeset 75540 are still a valid cure. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Tue, 03 Jul 2012 20:58:08 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:12</guid> <description> <p> As you can see from the comments above yours, the patch in <a class="changeset" href="https://svn.boost.org/trac10/changeset/75540" title="attempting to address #6131">[75540]</a>, which was released as part of Boost 1.49, caused more problems than it solved. The bug is unfortunate, but there is nothing that can be done at this point, AFAIK. Sorry. </p> </description> <category>Ticket</category> </item> <item> <author>monster.romster@…</author> <pubDate>Sat, 07 Jul 2012 01:44:45 GMT</pubDate> <title>version changed; cc set https://svn.boost.org/trac10/ticket/6131#comment:13 https://svn.boost.org/trac10/ticket/6131#comment:13 <ul> <li><strong>cc</strong> <span class="trac-author">monster.romster@…</span> added </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.49.0</span> → <span class="trac-field-new">Boost 1.50.0</span> </li> </ul> <p> I tried that patch <a class="ext-link" href="https://svn.boost.org/trac/boost/changeset/75540"><span class="icon">​</span>https://svn.boost.org/trac/boost/changeset/75540</a> but then boost fails to compile: </p> <pre class="wiki"> "ccache" "g++" -ftemplate-depth-128 -O2 -march=i686 -pipe -O3 -Wno-deprecated -fno-strict-aliasing -finline-functions -Wno-inline -Wall -fPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_GRAPH_DYN_LINK=1 -DBOOST_HAS_ICU=1 -DNDEBUG -I"." -I"/usr/include" -I"libs/graph/src" -c -o "bin.v2/libs/graph/build/gcc-4.5.3/release/graphml.o" "libs/graph/src/graphml.cpp" In file included from libs/graph/src/graphml.cpp:14:0: ./boost/foreach.hpp:126:16: error: 'boost::boost::mpl' has not been declared ./boost/foreach.hpp:126:21: error: expected '{' before 'false_' ./boost/foreach.hpp:127:5: error: invalid type in declaration before '{' token ./boost/foreach.hpp:127:5: error: template declaration of 'int boost::boost::foreach::false_' ./boost/foreach.hpp:127:5: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x ./boost/foreach.hpp:137:16: error: 'boost::boost::mpl' has not been declared ./boost/foreach.hpp:137:21: error: expected '{' before 'or_' ./boost/foreach.hpp:137:24: error: expected initializer before '&lt;' token In file included from libs/graph/src/graphml.cpp:14:0: ./boost/foreach.hpp:168:8: error: 'BOOST_FOREACH' in namespace 'boost::boost' does not name a type </pre><p> So I am forced to keep boost at 1.49.0 due to wesnoth failing on 1.50.0 </p> <pre class="wiki">[ 15%] Building CXX object src/CMakeFiles/wesnoth-game.dir/font.cpp.o In file included from /usr/ports/work/wesnoth/src/wesnoth-1.10.3/src/shared_object.hpp:21:0, from /usr/ports/work/wesnoth/src/wesnoth-1.10.3/src/tstring.hpp:19, from /usr/ports/work/wesnoth/src/wesnoth-1.10.3/src/config.hpp:40, from /usr/ports/work/wesnoth/src/wesnoth-1.10.3/src/terrain.hpp:18, from /usr/ports/work/wesnoth/src/wesnoth-1.10.3/src/map.hpp:23, from /usr/ports/work/wesnoth/src/wesnoth-1.10.3/src/builder.cpp:26: /usr/ports/work/wesnoth/src/wesnoth-1.10.3/src/foreach.hpp:9:22: error: 'boost::BOOST_FOREACH' has not been declared make[2]: *** [src/CMakeFiles/wesnoth-game.dir/builder.cpp.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [src/CMakeFiles/wesnoth-game.dir/all] Error 2 make: *** [all] Error 2 =======&gt; ERROR: Building '/var/ports/packages/wesnoth#1.10.3-1.pkg.tar.gz' failed. </pre><p> Lets hope boost 1.51.0 fixes this, or is wesnoth 1.10.3 doing something wrong? </p> <p> Regards, Danny Rawlins Romster @ freenode distro <a class="ext-link" href="http://crux.nu"><span class="icon">​</span>http://crux.nu</a> </p> Ticket Eric Niebler Sat, 07 Jul 2012 06:59:06 GMT <link>https://svn.boost.org/trac10/ticket/6131#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:14</guid> <description> <p> There is no fix that doesn't cause more problems than it solves, to the best of my knowledge. No changes are planned for 1.51. Simply do not #define foreach to anything and you should avoid this problem entirely. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 12 Jul 2012 14:30:41 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:15 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:15</guid> <description> <p> Someone should then update the documentation (<a href="http://www.boost.org/doc/libs/1_50_0/doc/html/foreach.html#foreach.introduction.making__literal_boost_foreach__literal__prettier">http://www.boost.org/doc/libs/1_50_0/doc/html/foreach.html#foreach.introduction.making__literal_boost_foreach__literal__prettier</a>) and clarify that "#define foreach should not be used". Thanks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 02 Oct 2012 06:17:11 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:16</guid> <description> <p> Congrats, boost, you managed to break compatibility in one of the simplest-to-use libraries, and nobody gives a damn enough to at least fix the docs. Good job. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Michel Morin</dc:creator> <pubDate>Tue, 02 Oct 2012 12:07:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:17 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:17</guid> <description> <p> The following treatment does not solve the problem, but it slightly improves the situation: </p> <p> In <code>boost/multi_index/hashed_index.hpp</code>, change </p> <pre class="wiki">/* Boost.Foreach compatibility */ template&lt; typename KeyFromValue,typename Hash,typename Pred, typename SuperMeta,typename TagList,typename Category &gt; inline boost::mpl::true_* boost_foreach_is_noncopyable( boost::multi_index::detail::hashed_index&lt; KeyFromValue,Hash,Pred,SuperMeta,TagList,Category&gt;*&amp;, boost::foreach::tag) { return 0; } </pre><p> into </p> <pre class="wiki">#if !(!defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \ || BOOST_WORKAROUND(BOOST_MSVC, &gt;= 1310) &amp;&amp; !defined(_PREFAST_) \ || (BOOST_WORKAROUND(__GNUC__, == 4) &amp;&amp; (__GNUC_MINOR__ &lt;= 5) &amp;&amp; !defined(BOOST_INTEL) &amp;&amp; \ !defined(BOOST_CLANG)) \ || (BOOST_WORKAROUND(__GNUC__, == 3) &amp;&amp; (__GNUC_MINOR__ &gt;= 4) &amp;&amp; !defined(BOOST_INTEL) &amp;&amp; \ !defined(BOOST_CLANG))) /* Boost.Foreach compatibility */ template&lt; typename KeyFromValue,typename Hash,typename Pred, typename SuperMeta,typename TagList,typename Category &gt; inline boost::mpl::true_* boost_foreach_is_noncopyable( boost::multi_index::detail::hashed_index&lt; KeyFromValue,Hash,Pred,SuperMeta,TagList,Category&gt;*&amp;, boost::foreach::tag) { return 0; } #endif </pre><p> and do the same thing for <code>boost/multi_index/ordered_index.hpp</code>, <code>boost/multi_index/random_access_index.hpp</code> and <code>boost/multi_index/sequenced_index.hpp</code>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Wed, 03 Oct 2012 18:30:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:18 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:18</guid> <description> <p> Can someone try defining their <code>foreach</code> macro like this: </p> <pre class="wiki">#include &lt;boost/foreach.hpp&gt; namespace boost { namespace BOOST_FOREACH = foreach; } #define foreach BOOST_FOREACH </pre><p> Let me know how that works for you. </p> </description> <category>Ticket</category> </item> <item> <author>linasvepstas@…</author> <pubDate>Thu, 11 Oct 2012 15:29:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:19 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:19</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6131#comment:18" title="Comment 18">eric_niebler</a>: </p> <blockquote class="citation"> <p> Can someone try defining their <code>foreach</code> macro like this: </p> <pre class="wiki">#include &lt;boost/foreach.hpp&gt; namespace boost { namespace BOOST_FOREACH = foreach; } #define foreach BOOST_FOREACH </pre><p> Let me know how that works for you. </p> </blockquote> <p> Does not work for boost-1.49 I get: error: declaration of namespace ‘boost::BOOST_FOREACH’ conflicts with ... </p> <p> /usr/local/include/boost/foreach_fwd.hpp:56:1: error: previous declaration of namespace ‘boost::BOOST_FOREACH’ here </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 11 Oct 2012 15:45:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:20 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:20</guid> <description> <p> Anyway, I hacked around this by surrounding above with #if BOOST_VERSION != 104900 which seems to work for that one installation, and also has been reported to work with other installations (MacOS, archlinux) running boost-1.50, which break if the above is NOT done. </p> <p> Original ticket: <a class="ext-link" href="https://bugs.launchpad.net/opencog/+bug/1057640/"><span class="icon">​</span>https://bugs.launchpad.net/opencog/+bug/1057640/</a> </p> </description> <category>Ticket</category> </item> <item> <author>linasvepstas@…</author> <pubDate>Thu, 11 Oct 2012 15:53:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:21 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:21</guid> <description> <p> To be completely clear: the following seems to work for multiple versions of boost (1.46, 1.48, 1.49, 1.50) and for multiple OS'es (MacOS, arch linux, multiple different ubuntu, RHEL4, and a cluster running old CentOS): </p> <pre class="wiki"> #include &lt;boost/foreach.hpp&gt; #include &lt;boost/version.hpp&gt; namespace boost { #if BOOST_VERSION != 104900 namespace BOOST_FOREACH = foreach; #endif } // namespace boost #define foreach BOOST_FOREACH </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 07 Dec 2012 12:33:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:22 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:22</guid> <description> <p> Note from boost foreach 1.52 documentation: </p> <pre class="wiki">I discourage this. It leads to name conflicts within the BOOST_FOREACH macro itself, where foreach is the name of a namespace </pre><p> Why can't you simply rename the boost::foreach namespace into something different? These changes would be much smaller than forcing the users of boost to rename their foreach macros in thousands of source files. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Mon, 10 Dec 2012 21:43:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6131#comment:23 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6131#comment:23</guid> <description> <p> Renaming the <code>foreach</code> namespace would be a breaking change. There are templates in the <code>foreach</code> namespace that end-users have specialized to make <code>BOOST_FOREACH</code> work with their types. All that would break if the <code>foreach</code> namespace changed. </p> </description> <category>Ticket</category> </item> </channel> </rss>