[C++-sig] Re: How to use call?

Dave Hawkes daveh at cadlink.com
Fri Jun 14 21:39:04 CEST 2002


"David Abrahams" <david.abrahams at rcn.com> wrote in message
news:097b01c213d4$232b7400$6601a8c0 at boostconsulting.com...
> >
> > where co is a callable object (constructor in this case).
>
> You mean a type/class? If it's an __init__ function you'll need an
argument
> for the object.

No, its the class type object itself. I suppose I shouldn't really call that
a constructor...

>
> That's a very strange way to invoke call<>. Did you look at the simple
> example at
>
>
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/
> python/doc/v2/call.html
>
> and the more-complete text at
>
>
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/
> python/doc/v2/callbacks.html
>

Yes, but due to some previous compile errors I review the docs agains the
source and wasn't sure if the comment about MSVC meant the parameter was
required or not.

> ?
>
> Looking at the source probably made you think you were supposed to pass it
> the address of a temporary boost::type<> object, but that's just a VC6
> workaround. Please look at the docs first and use the source as a last
> resort.
>
> > I know the intention here is to copy the lvalue
>
> Huh? Which lvalue?
>

The lvalue_from_python code that seems to get invoked

> > and prevent pointer conversions, but if the returned value is a class we
> don't want to copy it
> > as we loose the benefit of the virtual function overrides.
>
> You seem to think that the result object will be copied no matter what.
> That's not right.
> If you want to return a pointer or reference, go ahead:
>
> MyClass* p = call<MyClass*>(callable, arg1, arg2, ...);
>

Then I  will get the "Attempt to return dangling internal reference"
exception because I need to take possesion of the returned object.

> > Maybe this will
> > be fixed when the object work is complete and the return type can be
> object.
>
> Not sure what you think that would buy you; you'd still need to get the
C++
> object out of it.
>

see above, the returned object needs to be 'owned'.

Dave Hawkes










More information about the Cplusplus-sig mailing list