[ptr_container] compiler error with BOOST_RESULT_OF_USE_DECLTYPE

Hello,
The following code:
#include

Nathan Ridge wrote:
Am I doing something wrong or is this a bug?
You're not doing wrong. This is caused by incorrect use of `result_of`. Changing the line 56 of boost/ptr_container/indirect_fun.hpp BOOST_DEDUCED_TYPENAME result_of< Fun( BOOST_DEDUCED_TYPENAME pointee<T>::type& ) >::type to BOOST_DEDUCED_TYPENAME result_of< const Fun( BOOST_DEDUCED_TYPENAME pointee<T>::type& ) >::type resolves the issue (`Fun` is changed to `const Fun`). Regards, Michel

Nathan Ridge wrote:
Am I doing something wrong or is this a bug?
You're not doing wrong. This is caused by incorrect use of `result_of`.
Changing the line 56 of boost/ptr_container/indirect_fun.hpp BOOST_DEDUCED_TYPENAME result_of< Fun( BOOST_DEDUCED_TYPENAME pointee::type& ) >::type to BOOST_DEDUCED_TYPENAME result_of< const Fun( BOOST_DEDUCED_TYPENAME pointee::type& ) >::type resolves the issue (`Fun` is changed to `const Fun`).
I still get the compiler error after making the change.
From the instantiation backtrace, the problematic result_of invocation is on line 108, not line 56 (but changing `Fun` to `const Fun` on line 108 doesn't help either).
Regards, Nate.

Nathan Ridge wrote:
You're not doing wrong. This is caused by incorrect use of `result_of`.
Changing the line 56 of boost/ptr_container/indirect_fun.hpp BOOST_DEDUCED_TYPENAME result_of< Fun( BOOST_DEDUCED_TYPENAME pointee::type& ) >::type to BOOST_DEDUCED_TYPENAME result_of< const Fun( BOOST_DEDUCED_TYPENAME pointee::type& ) >::type resolves the issue (`Fun` is changed to `const Fun`).
I still get the compiler error after making the change.
Oh sorry, I tested with the trunk version... Regards, Michel

Michel MORIN wrote:
This is caused by incorrect use of `result_of`.
Changing the line 56 of boost/ptr_container/indirect_fun.hpp BOOST_DEDUCED_TYPENAME result_of< Fun( BOOST_DEDUCED_TYPENAME pointee::type& ) >::type to BOOST_DEDUCED_TYPENAME result_of< const Fun( BOOST_DEDUCED_TYPENAME pointee::type& ) >::type resolves the issue (`Fun` is changed to `const Fun`).
The above is completely wrong. Sorry for the noise. Regards, Michel

On 25/02/2011 11:57, Thorsten Ottosen wrote:
On 2/25/2011 8:30 AM, Nathan Ridge wrote:
Hello,
The following code:
#include
struct A { bool operator<(const A&) const; }; The compiler is pretty clear about it. Define
bool operator<( const A&, const A& );
Is that the infamous ternary operator

On 25/02/2011 08:30, Nathan Ridge wrote:
Hello,
The following code:
#include
struct A { bool operator<(const A&) const; }; int main() { boost::ptr_set<A> s; return 0; } gives the following compiler errors when compiling with BOOST_RESULT_OF_USE_DECLTYPE defined:
[...] It's a bug yes. File a ticket.

Hello,
The following code:
#include struct A { bool operator<(const A&) const; }; int main() { boost::ptr_set s; return 0; }
gives the following compiler errors when compiling with BOOST_RESULT_OF_USE_DECLTYPE defined: [...]
It's a bug yes. File a ticket.
I filed https://svn.boost.org/trac/boost/ticket/5232 Regards, Nate.

A similar error happens even with tr1 result_of (i.e. without defining
BOOST_RESULT_OF_USE_DECLTYPE).
Minimal test case (fails to be compiled):
#include

Den 01-03-2011 21:30, Michel MORIN skrev:
The error occurred in the code (at line 105 of ptr_container/indirect_fun.hpp) which determines the return type of unary function call operator of class boost::void_ptr_indirect_fun
: result_of
::type operator()( const void* r ) const {...} Since result_of
only works with two function parameters, this code does not compile. These issues, including OP's one, can be fixed by removing unary function call operator of class boost::void_ptr_indirect_fun (i.e. making it BinaryFunction).
The problem then is that we can't use the class with unary functions. Something that might already we be done by users. -Thorsten

Thorsten Ottosen wrote:
These issues, including OP's one, can be fixed by removing unary function call operator of class boost::void_ptr_indirect_fun (i.e. making it BinaryFunction).
The problem then is that we can't use the class with unary functions. Something that might already we be done by users.
So, how about adding void_ptr_indirect_binary_fun (and void_ptr_indirect_unary_fun)? Then we have void_ptr_indirect_fun (with unary and binary function call operators) void_ptr_indirect_unary_fun (with unary function call operator) void_ptr_indirect_biary_fun (with binary function call operator) and use void_ptr_indirect_binary_fun when wrapping comparators. Regards, Michel

On 3/3/2011 12:13 AM, Michel MORIN wrote:
Thorsten Ottosen wrote:
These issues, including OP's one, can be fixed by removing unary function call operator of class boost::void_ptr_indirect_fun (i.e. making it BinaryFunction).
The problem then is that we can't use the class with unary functions. Something that might already we be done by users.
So, how about adding void_ptr_indirect_binary_fun (and void_ptr_indirect_unary_fun)? Then we have void_ptr_indirect_fun (with unary and binary function call operators) void_ptr_indirect_unary_fun (with unary function call operator) void_ptr_indirect_biary_fun (with binary function call operator) and use void_ptr_indirect_binary_fun when wrapping comparators.
I was messing around with enable_if to see if we could detect the number
of arguments. But I couldn't find a traits that does that yesterday ...
now I see

Thorsten Ottosen wrote:
I was messing around with enable_if to see if we could detect the number of arguments. But I couldn't find a traits that does that yesterday ... now I see
could help. This way I think we can avoid instantiating result_of until it works.
Note that you cannot use SFINAE based on template `Fun`'s arity
since `Fun` is not a template parameter of void_ptr_indirect_fun's operator().
To avoid unnecessary instanciation of result_of,
we might need to make operator() a function template and
make its return type a dependent type of its template parameters.
The following code works fine:
#include

Den 03-03-2011 14:39, Michel MORIN skrev:
Thorsten Ottosen wrote:
To avoid unnecessary instanciation of result_of, we might need to make operator() a function template and make its return type a dependent type of its template parameters.
The following code works fine:
Thanks. This is excellent. I have only made minor changes. The change is comitted to trunk ... if it goes well, then it can go to release. Check it out if you have the time. cheers -Thorsten

Thorsten Ottosen wrote:
The change is comitted to trunk ... if it goes well, then it can go to release. Check it out if you have the time.
Great! I looked at the code and test it with GCC 4.6.
* For indirect_fun, make_lazy is not necessary because the return type of
its operator() is already a dependent type.
* For indirect_fun, pointee in result_of should not be removed. This broke
test/indirect_fun.cpp when compiling with BOOST_RESULT_OF_USE_DECLTYPE.
*

Den 04-03-2011 08:37, Michel MORIN skrev:
Michel MORIN wrote:
I attached a patch for fixing these problems. After applying this patch, the OP's code, my code with my_less comparator and test/indirect_fun.cpp all run fine (w/wo BOOST_RESULT_OF_USE_DECLTYPE).
Ouch! Forgot to attach a patch.
Thanks. Applied to trunk. regards -Thorsten
participants (4)
-
Mathias Gaunard
-
Michel MORIN
-
Nathan Ridge
-
Thorsten Ottosen