Boost C++ Libraries: Ticket #7753: Allow result_of to fall back on decltype https://svn.boost.org/trac10/ticket/7753 <p> result_of uses decltype by default on very few compilers, since most current compilers' decltype support doesn't work for some TR1-style usage. </p> <p> Many of those same compilers support C++11 lambdas which don't follow TR1 result_of protocol. Currently, this makes lambdas very difficult to use with other code using result_of. </p> <p> The attached code allows compilers which partially support decltype to use it only on functors which don't publish a result_type or result struct. </p> <p> It also contains tests &amp; doc changes. Compiled with VC10, clang++3.1 &amp; g++4.5 (both compilers with and without -std=c++0x). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7753 Trac 1.4.3 Michel Morin Sat, 01 Dec 2012 10:35:47 GMT attachment set https://svn.boost.org/trac10/ticket/7753 https://svn.boost.org/trac10/ticket/7753 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">result_of.diff</span> </li> </ul> <p> Patch by Nathan Crookston </p> Ticket Michel Morin Sat, 01 Dec 2012 10:36:20 GMT <link>https://svn.boost.org/trac10/ticket/7753#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7753#comment:1</guid> <description> <p> Attached a patch by Nathan Crookston </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Daniel Walker</dc:creator> <pubDate>Sat, 01 Dec 2012 17:43:05 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7753#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7753#comment:2</guid> <description> <p> Currently, result_of has two "modes" of operation: TR1 mode and decltype mode. Users can select the mode via the BOOST_RESULT_OF_USE_TR1 and BOOST_RESULT_OF_USE_DECLTYPE macros. You are proposing a third mode, a hybrid mode, in which result_of would operate in TR1 or decltype mode depending on whether or not the function object employs the TR1 protocol. The hybrid mode would be appealing to projects that sometimes require full decltype support (e.g. using result_of with incomplete return types) and sometimes do not (e.g. using result_of with C++11 lambdas). The hybrid mode would allow users to selectively employ the TR1 protocol to workaround deficiencies in their compiler's decltype support. Such workarounds are already possible, however, in user code (e.g. defining BOOST_RESULT_OF_USE_DECLTYPE while routing legacy TR1 code to boost::tr1::result_of&lt;&gt;), though these user-level workarounds could be cumbersome in some situations. </p> <p> The proposal may have some merit, but it also has some costs. My immediate inclination is to leave things as they are for two reasons: 1) usually decltype is a good alternative to the TR1 protocol even on compilers where it is not fully supported, in which case there are already workarounds for the corner cases; 2) two result_of modes are simpler than three. However, I would suggest that you start a thread on the Boost developer mailing list to discuss your proposal and solicit the thoughts of others. </p> </description> <category>Ticket</category> </item> <item> <author>nathan.crookston+boost@…</author> <pubDate>Sat, 01 Dec 2012 18:01:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7753#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7753#comment:3</guid> <description> <p> Thanks, Daniel. This patch was actually created in response to a thread: </p> <p> <a class="ext-link" href="http://boost.2283326.n4.nabble.com/Range-amp-c-0x-Lambdas-Can-this-be-done-td4638947.html"><span class="icon">​</span>http://boost.2283326.n4.nabble.com/Range-amp-c-0x-Lambdas-Can-this-be-done-td4638947.html</a> </p> <p> I would be concerned about using a non-industrial strength decltype on a whole project basis (e.g., if my project used Proto, which requries N3276), and concerned about enabling decltype on a translation unit-by-translation unit basis (potential ODR problems). </p> </description> <category>Ticket</category> </item> <item> <author>Nathan Crookston <nathan.crookston+boost@…></author> <pubDate>Wed, 10 Apr 2013 17:17:19 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/7753 https://svn.boost.org/trac10/ticket/7753 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">result_of.patch</span> </li> </ul> <p> Updated to use _CXX11_ style macros. </p> Ticket Daniel Walker Wed, 03 Jul 2013 22:14:28 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/7753#comment:4 https://svn.boost.org/trac10/ticket/7753#comment:4 <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/84949" title="added new result_of mode that uses TR1 with a decltype fallback as ...">[84949]</a>) added new result_of mode that uses TR1 with a decltype fallback as suggested by Nathan Crookston; fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7753" title="#7753: Feature Requests: Allow result_of to fall back on decltype (closed: fixed)">#7753</a> </p> Ticket