Opened 5 years ago

Last modified 5 years ago

#9112 new Bugs

[tr1] Failures in test_ref_wrapper_tricky.cpp

Reported by: Petr Machata <pmachata@…> Owned by: Peter Dimov
Milestone: To Be Determined Component: result_of
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:


The mentioned test case gives a number of failures. Those can be tracked down to two problems (at least the test case perceives them as problems). Google gives hits dating this back to 1.37, I have confirmed it with 1.41 and 1.54. I'm not sure why this hasn't been addressed--have I inadvertently opened a can of worms?

First, reference_wrapper that wraps function-like objects doesn't derive off std::unary_function, resp. std::binary function. That's relatively easy to fix by introducing a reference_wrapper_base class template, that reference_wrapper inherits off. That template optionally derives off unary_ or binary_function as appropriate.

Second, calling reference wrapper as function doesn't work for member functions. This can be solved by introducing operator() in the above mentioned base class.

I'll attach a patch that implements the above, except for specializations for reference_wrapper<{binary,unary}_function>. Please let me know whether a patch to this effect would be applicable and advise on areas that need more work.

Attachments (1)

boost-0.41.0-tr1-ref.patch (3.3 KB) - added by Petr Machata <pmachata@…> 5 years ago.
Proposed patch.

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by Petr Machata <pmachata@…>

Attachment: boost-0.41.0-tr1-ref.patch added

Proposed patch.

comment:1 Changed 5 years ago by Petr Machata <pmachata@…>

The errors reported by the test case look like this:

gcc.compile.c++ ../../../bin.v2/libs/tr1/test/test_ref_wrapper_tricky.test/gcc-4.6.3/debug/test_ref_wrapper_tricky.o
test_ref_wrapper_tricky.cpp: In function 'int main()':
test_ref_wrapper_tricky.cpp:42:220: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>' 
test_ref_wrapper_tricky.cpp:42:221: error: template argument 1 is invalid
test_ref_wrapper_tricky.cpp:42:254: error: invalid type in declaration before ';' token
test_ref_wrapper_tricky.cpp:48:227: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>' 
test_ref_wrapper_tricky.cpp:48:228: error: template argument 1 is invalid
test_ref_wrapper_tricky.cpp:48:261: error: invalid type in declaration before ';' token
test_ref_wrapper_tricky.cpp:64:34: error: no match for call to '(boost::reference_wrapper<functor1>) (int&)'
test_ref_wrapper_tricky.cpp:75:41: error: no match for call to '(boost::reference_wrapper<functor2>) (int&, int&)'
test_ref_wrapper_tricky.cpp:79:9: warning: unused variable 'ri' [-Wunused-variable]
test_ref_wrapper_tricky.cpp:80:15: warning: unused variable 'cri' [-Wunused-variable]

Those two are from the unary_function and binary_function specializations that I haven't fixed, as mentioned above.

comment:2 Changed 5 years ago by John Maddock

Component: TR1result_of
Owner: changed from John Maddock to Peter Dimov

Reassigning as this is an issue with Boost.Ref not really TR1.

Note: See TracTickets for help on using tickets.