Boost C++ Libraries: Ticket #6555: output_test_stream does not play nicely with std::ref() (GCC 4.6.1, C++2011 mode) https://svn.boost.org/trac10/ticket/6555 <p> Under GCC 4.6.1 with Boost 1.48.0 and C++2011 turned on (as it was for the compile of Boost), the following code fails to compile (with appropriate wrapping): </p> <div class="wiki-code"><div class="code"><pre><span class="n">boost</span><span class="o">::</span><span class="n">test_tools</span><span class="o">::</span><span class="n">output_test_stream</span> <span class="n">os</span><span class="p">;</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="n">std</span><span class="o">::</span><span class="n">ref</span><span class="p">(</span><span class="n">os</span><span class="p">);</span> </pre></div></div><p> The relevant part of the error message is (I believe): </p> <pre class="wiki">.../include/boost/test/output_test_stream.hpp:42:37: error: 'typedef class boost::test_tools::predicate_result boost::test_tools::output_test_stream::result_type' is private .../bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.1/../../../../include/c++/4.6.1/functional:74:46: error: within this context </pre><p> It seems that the GCC <code>std::ref()</code> function is trying to pick out a nested <code>result_type</code> if defined in order to ascertain whether <code>output_test_stream</code> is callable. Unfortunately <code>result_type</code> is defined but private, which causes a compile error in the template code. </p> <p> Solutions: </p> <p> (1) Use <code>predicate_result</code> directly instead of using a typedef at all. </p> <p> (2) Make the typedef public (may cause problems based on what <code>std::ref()</code> does next when it <strong>does</strong> think output_test_stream is callable). </p> <p> (3) Call it something other than <code>result_type</code>. </p> <p> Thanks for your help. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6555 Trac 1.4.3 Gennadiy Rozental Tue, 13 Nov 2012 12:55:17 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6555#comment:1 https://svn.boost.org/trac10/ticket/6555#comment:1 <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/81322" title="avoid result_type Fixes #6555 ">[81322]</a>) avoid result_type Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6555" title="#6555: Bugs: output_test_stream does not play nicely with std::ref() (GCC 4.6.1, ... (closed: fixed)">#6555</a> </p> Ticket