Opened 9 years ago

Closed 8 years ago

#9860 closed Bugs (fixed)

mem_fun_cxx98 doesn't compile with c++11

Reported by: chris.cooper@… Owned by: Douglas Gregor
Milestone: Boost 1.56.0 Component: function
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

Using clang++ from XCode 5.1 on OSX 10.9.2, mem_fun_cxx98 won't compile, it gives this error:

mem_fun_cxx98.cpp:34:46: error: invalid operands to binary expression ('std::1::basic_ostream<char>' and 'ostream' (aka 'basic_ostream<char>'))

BOOST_TEST(f2(&x, boost::ref(std::cout)) == std::cout);

../../../boost/detail/lightweight_test.hpp:186:28: note: expanded from macro 'BOOST_TEST' #define BOOST_TEST(expr) ((expr)? (void)0: ::boost::detail::test_failed_impl(#expr, FILE, LINE, BOOST_CURRENT_FUNCTION)) 1 error generated.

Peter Dimov suggested the following fix:

It should probably say

BOOST_TEST( &f2(&x, boost::ref(std::cout)) == &std::cout );

You can say std::cout == std::cout in pre-C++11, but it doesn't do anything sensible. This no longer compiles in C++11.

Change History (3)

comment:1 by chris.cooper@…, 9 years ago

The same problem exists (with the same solution) for mem_fun_portable.cpp

comment:2 by Niklas Angare <li51ckf02@…>, 8 years ago

Component: Regression Testingfunction
Owner: changed from René Rivera to Douglas Gregor

comment:3 by Marshall Clow, 8 years ago

Milestone: To Be DeterminedBoost 1.56.0
Resolution: fixed
Status: newclosed

This has been fixed, but not made it into a release yet. It will be part of the 1.56.0 release.

  • commit 78eb6b1c8c2492fea1783c09e946d094a8a5e905
  • Author: Marshall Clow <marshall@…>
  • Date: Mon Feb 3 11:46:05 2014 -0800

Fixed two tests to work with C++11/libc++. The tests attempted to compare two ostream&, but didn't really. In c++03, both decayed to void *, which wre then compared. In c++11, the ostreams are comvertible to bool, but only explicitly, and this failed to compile. Use a custom struct with operator== instead of ostream in these tests instead.

Note: See TracTickets for help on using tickets.