Boost C++ Libraries: Ticket #12778: Boost.Test is broken against left shift operator in certain cases https://svn.boost.org/trac10/ticket/12778 <pre class="wiki">BOOST_CHECK_EQUAL(nullptr, nullptr); </pre><p> results in </p> <pre class="wiki">/usr/include/boost/type_traits/detail/has_binary_operator.hpp: In instantiation of ‘const bool boost::detail::has_left_shift_impl::operator_exists&lt;std::basic_ostream&lt;char&gt;, std::nullptr_t&gt;::value’: /usr/include/boost/type_traits/detail/has_binary_operator.hpp:179:4: required from ‘const bool boost::detail::has_left_shift_impl::trait_impl1&lt;std::basic_ostream&lt;char&gt;, std::nullptr_t, boost::detail::has_left_shift_impl::dont_care, false&gt;::value’ /usr/include/boost/type_traits/detail/has_binary_operator.hpp:208:4: required from ‘const bool boost::detail::has_left_shift_impl::trait_impl&lt;std::basic_ostream&lt;char&gt;, std::nullptr_t, boost::detail::has_left_shift_impl::dont_care&gt;::value’ /usr/include/boost/type_traits/detail/has_binary_operator.hpp:216:8: required from ‘struct boost::has_left_shift&lt;std::basic_ostream&lt;char&gt;, std::nullptr_t, boost::detail::has_left_shift_impl::dont_care&gt;’ /usr/include/boost/test/tools/detail/print_helper.hpp:47:5: required from ‘struct boost::test_tools::tt_detail::print_log_value&lt;std::nullptr_t&gt;’ /usr/include/boost/test/tools/detail/print_helper.hpp:178:5: required from ‘std::ostream&amp; boost::test_tools::tt_detail::operator&lt;&lt;(std::ostream&amp;, const boost::test_tools::tt_detail::print_helper_t&lt;T&gt;&amp;) [with T = std::nullptr_t; std::ostream = std::basic_ostream&lt;char&gt;]’ /usr/include/boost/test/tools/assertion.hpp:163:1: required from ‘static void boost::test_tools::assertion::op::EQ&lt;Lhs, Rhs, Enabler&gt;::report(std::ostream&amp;, const PrevExprType&amp;, const Rhs&amp;) [with PrevExprType = boost::test_tools::assertion::value_expr&lt;firewall::deep_const_ptr&lt;void*&gt;&amp;&gt;; Lhs = firewall::deep_const_ptr&lt;void*&gt;; Rhs = std::nullptr_t; Enabler = void; std::ostream = std::basic_ostream&lt;char&gt;]’ /usr/include/boost/test/tools/assertion.hpp:355:26: required from ‘void boost::test_tools::assertion::binary_expr&lt;Lhs, Rhs, OP&gt;::report(std::ostream&amp;) const [with LExpr = boost::test_tools::assertion::value_expr&lt;firewall::deep_const_ptr&lt;void*&gt;&amp;&gt;; Rhs = std::nullptr_t; OP = boost::test_tools::assertion::op::EQ&lt;firewall::deep_const_ptr&lt;void*&gt;, std::nullptr_t, void&gt;; std::ostream = std::basic_ostream&lt;char&gt;]’ /usr/include/boost/test/tools/assertion.hpp:365:15: required from ‘boost::test_tools::assertion_result boost::test_tools::assertion::binary_expr&lt;Lhs, Rhs, OP&gt;::evaluate(bool) const [with LExpr = boost::test_tools::assertion::value_expr&lt;firewall::deep_const_ptr&lt;void*&gt;&amp;&gt;; Rhs = std::nullptr_t; OP = boost::test_tools::assertion::op::EQ&lt;firewall::deep_const_ptr&lt;void*&gt;, std::nullptr_t, void&gt;]’ /usr/include/boost/type_traits/detail/has_binary_operator.hpp:158:70: error: ambiguous overload for ‘operator&lt;&lt;’ (operand types are ‘std::basic_ostream&lt;char&gt;’ and ‘std::nullptr_t’) BOOST_STATIC_CONSTANT(bool, value = (sizeof(s_check(((make&lt;Lhs&gt;() BOOST_TT_TRAIT_OP make&lt;Rhs&gt;()),make&lt;has_operator&gt;())))==sizeof(::boost::type_traits::yes_type))); </pre><p> no matter what I try to alleviate it, including: </p> <pre class="wiki">#define BOOST_TEST_NO_OLD_TOOLS </pre><pre class="wiki">BOOST_TEST_DONT_PRINT_LOG_VALUE(::std::nullptr_t) </pre><pre class="wiki">template &lt;class CharT, class TraitsT&gt; inline ::std::basic_ostream&lt;CharT, TraitsT&gt;&amp; operator&lt;&lt;(::std::basic_ostream&lt;CharT, TraitsT&gt;&amp; os, std::nullptr_t const&amp;) { return os; } </pre><pre class="wiki">namespace boost { namespace test_tools { namespace tt_detail { template &lt;class CharT, class TraitsT&gt; inline ::std::basic_ostream&lt;CharT, TraitsT&gt;&amp; operator&lt;&lt;(::std::basic_ostream&lt;CharT, TraitsT&gt;&amp; os, std::nullptr_t const&amp;) { return os; } } // namespace tt_detail } // namespace test_tools } // namespace boost </pre><pre class="wiki">namespace my_namespace { template &lt;class CharT, class TraitsT&gt; inline ::std::basic_ostream&lt;CharT, TraitsT&gt;&amp; operator&lt;&lt;(::std::basic_ostream&lt;CharT, TraitsT&gt;&amp; os, std::nullptr_t const&amp;) { return os; } } // namespace my_namespace </pre><p> etc., etc., etc. I also cannot understand what's the problem. I mean theoretically it should work but it does not. Furthermore, I've discovered another problem. Doing </p> <pre class="wiki">#define BOOST_TEST_NO_OLD_TOOLS </pre><p> and then </p> <pre class="wiki">::std::ofstream ofs("xxx"); BOOST_REQUIRE(ofs); </pre><p> results in </p> <pre class="wiki">/usr/include/boost/test/utils/wrap_stringstream.hpp: In instantiation of ‘boost::basic_wrap_stringstream&lt;CharT&gt;&amp; boost::operator&lt;&lt;(boost::basic_wrap_stringstream&lt;CharT&gt;&amp;, const T&amp;) [with CharT = char; T = std::basic_ofstream&lt;char&gt;]’: /usr/include/boost/test/tools/assertion.hpp:312:93: required from ‘static void boost::test_tools::assertion::value_expr&lt;T&gt;::format_message(boost::wrap_stringstream&amp;, const U&amp;) [with U = std::basic_ofstream&lt;char&gt;; T = std::basic_ofstream&lt;char&gt;&amp;; boost::wrap_stringstream = boost::basic_wrap_stringstream&lt;char&gt;]’ /usr/include/boost/test/tools/assertion.hpp:305:23: required from ‘boost::test_tools::assertion_result boost::test_tools::assertion::value_expr&lt;T&gt;::evaluate(bool) const [with T = std::basic_ofstream&lt;char&gt;&amp;]’ /usr/include/boost/test/utils/wrap_stringstream.hpp:66:19: error: no match for ‘operator&lt;&lt;’ (operand types are ‘boost::basic_wrap_stringstream&lt;char&gt;::wrapped_stream {aka std::__cxx11::basic_ostringstream&lt;char&gt;}’ and ‘const std::basic_ofstream&lt;char&gt;’) targ.stream() &lt;&lt; t; /usr/include/boost/test/utils/wrap_stringstream.hpp:66:19: note: candidate: operator&lt;&lt;(int, int) &lt;built-in&gt; /usr/include/boost/test/utils/wrap_stringstream.hpp:66:19: note: no known conversion for argument 2 from ‘const std::basic_ofstream&lt;char&gt;’ to ‘int’ In file included from /usr/include/c++/6.2.1/iterator:64:0, from ../../include/process/args.hpp:42, from ../../include/process/args:35, from /home/aks/Projects/Bitbucket/Process/Source/test/source/process/stdi.t.cpp:38: /usr/include/c++/6.2.1/ostream:108:7: note: candidate: std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; std::basic_ostream&lt;_CharT, _Traits&gt;::operator&lt;&lt;(std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp; (*)(std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type&amp;)) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;; std::basic_ostream&lt;_CharT, _Traits&gt;::__ostream_type = std::basic_ostream&lt;char&gt;] operator&lt;&lt;(__ostream_type&amp; (*__pf)(__ostream_type&amp;)) </pre><p> and the workaround it of course </p> <pre class="wiki">BOOST_REQUIRE(bool(ofs)); </pre><p> which is a no go in the long run. </p> <p> Looking forward to your assistance. Regards. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12778 Trac 1.4.3 Raffi Enficiaud Mon, 30 Jan 2017 21:28:34 GMT owner changed https://svn.boost.org/trac10/ticket/12778#comment:1 https://svn.boost.org/trac10/ticket/12778#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Gennadiy Rozental</span> to <span class="trac-author">Raffi Enficiaud</span> </li> </ul> <p> I believe the problems rather comes from <code>nullptr</code> which does not seem to be supported. </p> Ticket anonymous Wed, 01 Feb 2017 21:19:01 GMT <link>https://svn.boost.org/trac10/ticket/12778#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12778#comment:2</guid> <description> <p> I've actually fixed the first problem with <code>nullptr</code>. Apparently, there was some problem with ADL in between. However, the second problem is there. Any ideas on it? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Wed, 01 Feb 2017 21:21:08 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12778#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12778#comment:3</guid> <description> <p> Sorry for not having posted an update. I fixed the issue on branch <code>origin/topic/12778-nullptr</code>. Would you please give a try? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Wed, 01 Mar 2017 11:33:54 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/12778#comment:4 https://svn.boost.org/trac10/ticket/12778#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> Merged to master, rev a2b73f5d7568e69162dfac213fab87eea0021ec5 </p> Ticket