[C++-sig] Re: return value policy for returning same python object...

Nikolay Mladenov nickm at sitius.com
Sun Jun 15 04:25:24 CEST 2003


What do you think about the following?

namespace boost { namespace python
{
     struct return_self : default_call_policies
    {
        static PyObject* postcall(PyObject *args, PyObject* ){
            return incref(PyTuple_GetItem(args,0));
        }
        struct result_converter
        {
            template <class T> struct apply{
                struct type{
                    static bool convertible() {return true;}
                    PyObject *operator()(T) const {return 0;}
                };
            };
        };
    };
}}







More information about the Cplusplus-sig mailing list