[C++-sig] Re: return value policy for returning same python object...
David Abrahams
dave at boost-consulting.com
Sun Jun 15 22:21:16 CEST 2003
Nikolay Mladenov <nickm at sitius.com> writes:
> <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
>
> <tt></tt> <tt></tt>
> <tt>David Abrahams wrote:</tt>
> <tt>Nikolay Mladenov <nickm at sitius.com> writes:</tt><tt></tt>
> <tt>> What do you think about the following?</tt>
> <tt>></tt>
> <tt>> namespace boost { namespace python</tt>
> <tt>> {</tt>
> <tt>> struct return_self : default_call_policies</tt>
> <tt>> {</tt>
> <tt>> static PyObject*
> postcall(PyObject *args, PyObject* ){</tt>
> <tt>>
> return incref(PyTuple_GetItem(args,0));</tt>
> <tt>> }</tt>
> <tt>> struct result_converter</tt>
> <tt>> {</tt>
> <tt>>
> template <class T> struct apply{</tt>
> <tt>>
> struct type{</tt>
> <tt>>
> static bool convertible() {return true;}</tt>
> <tt>>
> PyObject *operator()(T) const {return 0;}</tt>
> <tt>
> ^</tt>
> <tt>I'd like to see ---------------------------^</tt><tt></tt>
> <tt> typename add_reference<typename add_const<T>::type>::type</tt><tt></tt>
> <tt>right here.</tt>
> <tt>What is the reason for that? Shouldn't this be optimised away anyway?</tt>
> <tt>Not that I mind it.</tt>
> <tt></tt> <tt></tt>
> <tt>>
> };</tt>
> <tt>>
> };</tt>
> <tt>> };</tt>
> <tt>> };</tt>
> <tt>> }}</tt><tt></tt>
> <tt>Otherwise, it looks great! If you'd like to write an HTML
> page for</tt>
> <tt>the reference manual and modify one of the tests to exercise it,
> I'd</tt>
> <tt>be happy to add it to the system.</tt>
> <tt>Sure.</tt>
> <tt></tt> <tt></tt>
No offense, but "ick!" Care to repost as plain text?
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list