[fusion] invoke_function_object and references

I have a function object that doesn't work with fusion's invoke_function_object. It is sensitive to whether arguments are passed by reference or by value, but when evaluating the result type, invoke_function_object strips top level references. On line 110 of invoke_function_object.hpp, there is: template <class Function, class Sequence> struct invoke_function_object_impl<Function,Sequence,N,true> { public: typedef typename boost::result_of< #define M(z,j,data) \ typename boost::remove_reference< \ typename result_of::at_c<Sequence,j>::type >::type Function (BOOST_PP_ENUM(N,M,~)) >::type result_type; #undef M What is the purpose of the remove_reference<> here, and can we get rid of it? -- Eric Niebler Boost Consulting www.boost-consulting.com

Eric Niebler wrote:
I have a function object that doesn't work with fusion's invoke_function_object.
Because it's noncopyable? The argument is taken by value unless we explicitly specify the template argument. IIRC it's even documented that it's valid to do so, somewhere :-). Regards, Tobias

Tobias Schwinger wrote:
Eric Niebler wrote:
I have a function object that doesn't work with fusion's invoke_function_object.
Because it's noncopyable?
The argument is taken by value unless we explicitly specify the template argument. IIRC it's even documented that it's valid to do so, somewhere :-).
No, you've completely misunderstood what I'm asking, so I'll ask it again:
It is sensitive to whether arguments are passed by reference or by value, but when evaluating the result type, invoke_function_object strips top level references. On line 110 of invoke_function_object.hpp, there is:
template <class Function, class Sequence> struct invoke_function_object_impl<Function,Sequence,N,true> { public:
typedef typename boost::result_of< #define M(z,j,data) \ typename boost::remove_reference< \ typename result_of::at_c<Sequence,j>::type >::type Function (BOOST_PP_ENUM(N,M,~)) >::type result_type; #undef M
What is the purpose of the remove_reference<> here, and can we get rid of it?
I'm talking about the calculation of the result type, and about top-level references being stripped from the argument types. The above code expands to something like: typedef typename boost::result_of< typename remove_reference< typename result_of::at_c<Sequence,0>::type >::type, typename remove_reference< typename result_of::at_c<Sequence,1>::type >::type, ...
::type result_type;
And I think it should be: typedef typename boost::result_of< typename result_of::at_c<Sequence,0>::type, typename result_of::at_c<Sequence,1>::type ...
::type result_type;
I have a sequence where some elements are references and some are values. And I have a function object that treats references and values differently. So, why are top-level references being stripped here? -- Eric Niebler Boost Consulting www.boost-consulting.com

I got the code expansion wrong. Corrected version below. Eric Niebler wrote:
The above code expands to something like:
typedef typename boost::result_of< Function ( typename remove_reference< typename result_of::at_c<Sequence,0>::type >::type, typename remove_reference< typename result_of::at_c<Sequence,1>::type >::type, ... )
::type result_type;
And I think it should be:
typedef typename boost::result_of< Function ( typename result_of::at_c<Sequence,0>::type, typename result_of::at_c<Sequence,1>::type ... )
::type result_type;
I have a sequence where some elements are references and some are values. And I have a function object that treats references and values differently. So, why are top-level references being stripped here?
-- Eric Niebler Boost Consulting www.boost-consulting.com

Eric Niebler wrote:
Tobias Schwinger wrote:
Eric Niebler wrote:
I have a function object that doesn't work with fusion's invoke_function_object. Because it's noncopyable?
The argument is taken by value unless we explicitly specify the template argument. IIRC it's even documented that it's valid to do so, somewhere :-).
No, you've completely misunderstood what I'm asking, so I'll ask it again:
<code> Oh yeah, obviously...
What is the purpose of the remove_reference<> here, and can we get rid of it?
After a deeper look I'm pretty sure that it's an artifact from before Boost.ResultOf times and that we can remove it. Tested and committed to the trunk. Thanks, Tobias
participants (2)
-
Eric Niebler
-
Tobias Schwinger