Boost logo

Boost Users :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2005-03-16 12:04:47


"Ian McCulloch" <ianmcc_at_[hidden]> wrote
> Peter Dimov wrote:
>
> > Ian McCulloch wrote:
> >>
> >> Yes, if you want to forward to a function but you don't know if it
> >> takes arguments by value or const reference.
> >
> > It doesn't matter. When you forward, you pass to result_of the exact
types
> > of the arguments you are supplying in the function (object) call, with a
> > reference when the argument is an lvalue.
> >
> > int x;
> > long y;
> > int const z;
> > int g();
> > int & h();
> >
> > f(x, y); // result_of<F(int&, long&)>
> > f(1, x); // result_of<F(int, int&)>
> > f(z, 4); // result_of<F(int const&, int)>
> > f( g(), h() ); // result_of<F(int, int&)>
> >
> > What is 'f' and how it takes its arguments in the cases above does not
> > affect how result_of is used.
>
> But what happens if F doesn't have an operator() overload that takes
> F(int const&, int) but only has F(int, int) ? It seems you need to know
> this in advance. I tried detecting it with SFINAE but that doesn't work;
I
> would have expected that if result<F(...)> has no member type then
> result_of<F(...)> would simply be an empty struct, but instead the program
> is ill-formed.
>
> What I am trying to do is forward calls to an object with an overloaded
> operator() and nested struct result defined appropriately, but I don't
know
> whether the operator() wants pass-by-value or pass-by-const-reference.

Are you sure you want result_of<> rather than typeof()? Would you consider
typeof emulation library, that is in the review queue right now?

Regards,
Arkadiy


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net