Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-11-11 11:53:52


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

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk