Opened 11 years ago

Closed 10 years ago

#6555 closed Bugs (fixed)

output_test_stream does not play nicely with std::ref() (GCC 4.6.1, C++2011 mode)

Reported by: greenc@… Owned by: Gennadiy Rozental
Milestone: To Be Determined Component: test
Version: Boost 1.48.0 Severity: Problem
Keywords: C++2011 Cc:

Description

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):

boost::test_tools::output_test_stream os;
(void) std::ref(os);

The relevant part of the error message is (I believe):

.../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

It seems that the GCC std::ref() function is trying to pick out a nested result_type if defined in order to ascertain whether output_test_stream is callable. Unfortunately result_type is defined but private, which causes a compile error in the template code.

Solutions:

(1) Use predicate_result directly instead of using a typedef at all.

(2) Make the typedef public (may cause problems based on what std::ref() does next when it does think output_test_stream is callable).

(3) Call it something other than result_type.

Thanks for your help.

Change History (1)

comment:1 by Gennadiy Rozental, 10 years ago

Resolution: fixed
Status: newclosed

(In [81322]) avoid result_type Fixes #6555

Note: See TracTickets for help on using tickets.