Boost C++ Libraries: Ticket #5127: Incorrect result_of usage in transform_iterator https://svn.boost.org/trac10/ticket/5127 <p> The documentation of <code>transform_iterator</code> says that <code>boost::result_of&lt;UnaryFunction(Iterator::reference)&gt;</code> is used to determine the functor return type. But this is incorrect; the correct one is <code>boost::result_of&lt;const UnaryFunction(Iterator::reference)&gt;</code>. </p> <p> This is because </p> <ol><li>The dereference operator of <code>transform_iterator</code> is a const member function. </li><li>So, in the dereference operator, <code>UnaryFunction</code> is treated as a const object. </li></ol><p> Accordingly, the code and the test need to be changed too. I will attach patches for the code, the test and the documentation. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5127 Trac 1.4.3 mimomorin@… Thu, 27 Jan 2011 01:03:17 GMT attachment set https://svn.boost.org/trac10/ticket/5127 https://svn.boost.org/trac10/ticket/5127 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">transform_iterator.patch</span> </li> </ul> <p> A patch for transform_iterator.hpp (against trunk) </p> Ticket mimomorin@… Thu, 27 Jan 2011 01:03:58 GMT attachment set https://svn.boost.org/trac10/ticket/5127 https://svn.boost.org/trac10/ticket/5127 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">transform_iterator_test.patch</span> </li> </ul> <p> A patch for transform_iterator_test.cpp (against trunk) </p> Ticket mimomorin@… Thu, 27 Jan 2011 01:04:51 GMT attachment set https://svn.boost.org/trac10/ticket/5127 https://svn.boost.org/trac10/ticket/5127 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">transform_iterator_doc.patch</span> </li> </ul> <p> A patch for transform_iterator_test's documents (against trunk) </p> Ticket mimomorin@… Thu, 27 Jan 2011 03:49:06 GMT <link>https://svn.boost.org/trac10/ticket/5127#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5127#comment:1</guid> <description> <p> The documentation patch (<code>transform_iterator_doc.patch</code>) fixes only <code>.html</code> and <code>.rst</code> files, and it doesn't touch <code>.pdf</code> file. Should <code>libs/iterator/doc/transform_iterator.pdf</code> be regenerated? </p> </description> <category>Ticket</category> </item> <item> <author>mimomorin@…</author> <pubDate>Thu, 27 Jan 2011 13:59:31 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/5127#comment:2 https://svn.boost.org/trac10/ticket/5127#comment:2 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.47.0</span> </li> </ul> Ticket mimomorin@… Wed, 02 Feb 2011 05:27:55 GMT summary changed https://svn.boost.org/trac10/ticket/5127#comment:3 https://svn.boost.org/trac10/ticket/5127#comment:3 <ul> <li><strong>summary</strong> <span class="trac-field-old">Documentation of transform_iterator is incorrect</span> → <span class="trac-field-new">Incorrect result_of usage in transform_iterator</span> </li> </ul> Ticket Michel Morin <mimomorin@…> Fri, 09 Sep 2011 10:58:11 GMT <link>https://svn.boost.org/trac10/ticket/5127#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5127#comment:4</guid> <description> <p> Ping? </p> <p> The test runs successfully on gcc 4.2 - 4.6 and clang (trunk). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>jeffrey.hellrung</dc:creator> <pubDate>Sun, 22 Apr 2012 01:27:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5127#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5127#comment:5</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/78121" title="refs #5127 applying Michael Morin's patch for transform_iterator to trunk">[78121]</a>) refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5127" title="#5127: Patches: Incorrect result_of usage in transform_iterator (closed: fixed)">#5127</a> applying Michael Morin's patch for transform_iterator to trunk </p> </description> <category>Ticket</category> </item> <item> <dc:creator>jeffrey.hellrung</dc:creator> <pubDate>Tue, 24 Apr 2012 21:28:14 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5127#comment:6 https://svn.boost.org/trac10/ticket/5127#comment:6 <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/78184" title="merging from trunk; fix #5127 from M. Morin; fix for refs #5697">[78184]</a>) merging from trunk; fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5127" title="#5127: Patches: Incorrect result_of usage in transform_iterator (closed: fixed)">#5127</a> from M. Morin; fix for refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5697" title="#5697: Bugs: iterator_facade::operator-&gt; is broken for proxy references (closed: fixed)">#5697</a> </p> Ticket TLBettens@… Sat, 18 Aug 2012 21:16:47 GMT <link>https://svn.boost.org/trac10/ticket/5127#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5127#comment:7</guid> <description> <h2 class="section" id="Warningmessageintroducedintorelease1_50_0">Warning message introduced into release 1_50_0</h2> <p> This change went into release 1-50_0 and now causes a warning message to be emitted in Visual C++ version 10, perhaps others versions as well. </p> <p> Compiler warning message: </p> <pre class="wiki">2&gt;c:\boostbuilding\boost_1_50_0\boost\iterator\transform_iterator.hpp(49): warning C4180: qualifier applied to function type has no meaning; ignored 2&gt; c:\boostbuilding\boost_1_50_0\boost\iterator\transform_iterator.hpp(70) : see reference to class template instantiation 'boost::detail::transform_iterator_base&lt;UnaryFunc,Iterator,Reference,Value&gt;' being compiled </pre><p> Workaround is to either revert back to release 1_49_0 by removing the <strong>const</strong>: </p> <pre class="wiki">boost::result_of&lt;/*const*/ UnaryFunction(Iterator::reference)&gt; </pre><p> , or disable the warning message using something like: </p> <pre class="wiki"> #if defined(BOOST_MSVC) # pragma warning (push) # pragma warning (disable:4180) // warning C4180: qualifier applied to function type has no meaning; ignored #endif typedef typename ia_dflt_help&lt; Reference , result_of&lt;const UnaryFunc(typename std::iterator_traits&lt;Iterator&gt;::reference)&gt; &gt;::type reference; #if defined(BOOST_MSVC) # pragma warning (pop) #endif </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Dave Abrahams</dc:creator> <pubDate>Sat, 18 Aug 2012 23:56:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5127#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5127#comment:8</guid> <description> <p> I support the latter change </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Michel Morin</dc:creator> <pubDate>Tue, 21 Aug 2012 14:57:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5127#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5127#comment:9</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5127#comment:7" title="Comment 7">TLBettens@…</a>: </p> <blockquote class="citation"> <p> This change went into release 1-50_0 and now causes a warning message to be emitted in Visual C++ version 10, perhaps others versions as well. </p> <p> Compiler warning message: </p> <pre class="wiki">c:\boostbuilding\boost_1_50_0\boost\iterator\transform_iterator.hpp(49): warning C4180: qualifier applied to function type has no meaning; ignored </pre></blockquote> <p> Thanks for the report. </p> <p> Hmm, it's strange... IIUC, <code>UnaryFunc</code> cannot be a function type. Could you post a (minimal) reproducible code for this problem? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 23 Aug 2012 02:29:30 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5127#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5127#comment:10</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5127#comment:9" title="Comment 9">michel</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5127#comment:7" title="Comment 7">TLBettens@…</a>: </p> <blockquote class="citation"> <p> This change went into release 1-50_0 and now causes a warning message to be emitted in Visual C++ version 10, perhaps others versions as well. </p> <p> Compiler warning message: </p> <pre class="wiki">c:\boostbuilding\boost_1_50_0\boost\iterator\transform_iterator.hpp(49): warning C4180: qualifier applied to function type has no meaning; ignored </pre></blockquote> <p> Thanks for the report. </p> <p> Hmm, it's strange... IIUC, <code>UnaryFunc</code> cannot be a function type. Could you post a (minimal) reproducible code for this problem? </p> </blockquote> <p> Thanks Michel for looking into it. I was able to reproduce the warning message with this code in main.cpp: </p> <pre class="wiki">#include &lt;boost/algorithm/string.hpp&gt; int main() { return 0; } </pre><p> Although not too exciting but perhaps helpful, the build log (CPPRocksProject.log) capturing the compile switches and warning message looks like: </p> <pre class="wiki">Build started 8/22/2012 7:04:55 PM. 1&gt;Project "D:\SAGR RIC v3\SAGR Development\MSVC++ Solution Space (2010)\CPPRocksProject\CPPRocksProject.vcxproj" on node 2 (build target(s)). 1&gt;InitializeBuildStatus: Creating "Win32\Debug\SAGR.unsuccessfulbuild" because "AlwaysCreate" was specified. MakeDirsForCl: Creating directory "D:\SAGR RIC v3\SAGR Development\MSVC++ Solution Space (2010)\CPPRocksProject\Win32\Debug\dumy\dumy\..\..\SourceCode". ClCompile: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\CL.exe /c /I"D:\SAGR RIC v3\SAGR Development\MSVC++ Solution Space (2010)\..\SourceCode\\" /IC:\BoostBuilding\boost_1_50_0\ /ZI /nologo /W4 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _MBCS /Gm /EHsc /RTCc /RTC1 /MTd /GS /Gy /fp:precise /fp:except /Za /Zc:wchar_t /Zc:forScope /GR /Fo"Win32\Debug\dumy\dumy\..\..\SourceCode\\" /Fd"Win32\Debug\vc100.pdb" /FR"Win32\Debug\dumy\dumy\..\..\SourceCode\\" /Gd /TP /wd4290 /wd4224 /analyze- /errorReport:prompt ..\..\SourceCode\main.cpp main.cpp 1&gt;c:\boostbuilding\boost_1_50_0\boost\iterator\transform_iterator.hpp(49): warning C4180: qualifier applied to function type has no meaning; ignored c:\boostbuilding\boost_1_50_0\boost\iterator\transform_iterator.hpp(70) : see reference to class template instantiation 'boost::detail::transform_iterator_base&lt;UnaryFunc,Iterator,Reference,Value&gt;' being compiled ManifestResourceCompile: c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\rc.exe /nologo /fo"Win32\Debug\SAGR-x86-Debug.exe.embed.manifest.res" Win32\Debug\SAGR-x86-Debug_manifest.rc Link: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"D:\SAGR RIC v3\SAGR Development\MSVC++ Solution Space (2010)\CPPRocksProject\Win32\Debug\SAGR-x86-Debug.exe" /INCREMENTAL /NOLOGO /LIBPATH:C:\BoostBuilding\boost_1_50_0\lib32\ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /ManifestFile:"Win32\Debug\SAGR-x86-Debug.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\SAGR RIC v3\SAGR Development\MSVC++ Solution Space (2010)\CPPRocksProject\Win32\Debug\SAGR-x86-Debug.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"D:\SAGR RIC v3\SAGR Development\MSVC++ Solution Space (2010)\CPPRocksProject\Win32\Debug\SAGR-x86-Debug.lib" /MACHINE:X86 "Win32\Debug\SAGR-x86-Debug.exe.embed.manifest.res" Win32\Debug\dumy\dumy\..\..\SourceCode\main.obj Manifest: c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\mt.exe /nologo /verbose /out:"Win32\Debug\SAGR-x86-Debug.exe.embed.manifest" /manifest "Win32\Debug\SAGR-x86-Debug.exe.intermediate.manifest" c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\rc.exe /nologo /fo"Win32\Debug\SAGR-x86-Debug.exe.embed.manifest.res" Win32\Debug\SAGR-x86-Debug_manifest.rc LinkEmbedManifest: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"D:\SAGR RIC v3\SAGR Development\MSVC++ Solution Space (2010)\CPPRocksProject\Win32\Debug\SAGR-x86-Debug.exe" /INCREMENTAL /NOLOGO /LIBPATH:C:\BoostBuilding\boost_1_50_0\lib32\ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /ManifestFile:"Win32\Debug\SAGR-x86-Debug.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\SAGR RIC v3\SAGR Development\MSVC++ Solution Space (2010)\CPPRocksProject\Win32\Debug\SAGR-x86-Debug.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"D:\SAGR RIC v3\SAGR Development\MSVC++ Solution Space (2010)\CPPRocksProject\Win32\Debug\SAGR-x86-Debug.lib" /MACHINE:X86 "Win32\Debug\SAGR-x86-Debug.exe.embed.manifest.res" Win32\Debug\dumy\dumy\..\..\SourceCode\main.obj CPPRocksProject.vcxproj -&gt; D:\SAGR RIC v3\SAGR Development\MSVC++ Solution Space (2010)\CPPRocksProject\Win32\Debug\SAGR-x86-Debug.exe BscMake: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\bscmake.exe /nologo /o"D:\SAGR RIC v3\SAGR Development\MSVC++ Solution Space (2010)\CPPRocksProject\Win32\Debug\SAGR-x86-Debug.bsc" Win32\Debug\dumy\dumy\..\..\SourceCode\main.sbr FinalizeBuildStatus: Deleting file "Win32\Debug\SAGR.unsuccessfulbuild". Touching "Win32\Debug\SAGR.lastbuildstate". 1&gt;Done Building Project "D:\SAGR RIC v3\SAGR Development\MSVC++ Solution Space (2010)\CPPRocksProject\CPPRocksProject.vcxproj" (build target(s)). Build succeeded. Time Elapsed 00:00:06.67 </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Michel Morin</dc:creator> <pubDate>Fri, 24 Aug 2012 14:52:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5127#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5127#comment:11</guid> <description> <p> OK, I figured out what the problem is. The problem is caused by the <code>/Za</code> compiler option. The <code>/Za</code> option is buggy and its use is not recommended (or rather, you shouldn't use it). By removing <code>/Za</code>, the warning gets disappeared. There is nothing wrong with the code in <code>transform_iterator.hpp</code>, and I think this warning problem would be "won't fix". </p> <p> The solution to this problem is </p> <blockquote> <p> <strong>Don't use <code>/Za</code>.</strong> </p> </blockquote> <p> See the posts from Stephan T. Lavavej (Visual C++ libraries developer) such as <a class="ext-link" href="http://thread.gmane.org/gmane.comp.compilers.clang.devel/21638/focus=21638"><span class="icon">​</span>this</a> and <a class="ext-link" href="http://thread.gmane.org/gmane.comp.lib.boost.devel/212140/focus=212186"><span class="icon">​</span>this</a>. Also, <a class="ext-link" href="https://svn.boost.org/trac/boost/wiki/Guidelines/WarningsGuidelines"><span class="icon">​</span>Boost's warning guidelines</a> might be useful for you. </p> </description> <category>Ticket</category> </item> <item> <author>TLBettens@…</author> <pubDate>Fri, 24 Aug 2012 15:04:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5127#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5127#comment:12</guid> <description> <p> Thanks. but I have to disagree. Turning off strict ISO/IEC compliance, i.e. enabling Microsoft extensions beyond the standard, isn't an advisable option for portable code. Let's not rely on a particular vender's extensions. We, as a community, really should be using any help from a compiler that helps us understand when we drift away. It is what it is, and if it's unfix able okay, but really, disabling the warning message seems prudent. Either way, thanks for considering it. </p> </description> <category>Ticket</category> </item> <item> <author>TLBettens@…</author> <pubDate>Fri, 24 Aug 2012 15:15:02 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5127#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5127#comment:13</guid> <description> <p> That said, if the /Za option is broken in VC 2010, it hard to argue with trying to use it. Thanks again!! Michel, I'll disable the extension. </p> </description> <category>Ticket</category> </item> </channel> </rss>