Skip to content

Support std::unique_ptr #60

@troopa81

Description

@troopa81

It's not possible to use std::unique_ptr as arguments. It works as returned value only.

Here is an example unique_ptr.zip

The problem is that even if we write the appropriate MappedType, the generated code that call the method with a std::unique_ptr argument should std::move this one

extern "C" {static PyObject *meth_Test_setObject(PyObject *, PyObject *);}
static PyObject *meth_Test_setObject(PyObject *sipSelf, PyObject *sipArgs)
{
...
    {
        std::unique_ptr<::AnObject>* a0;
        ::Test *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ3", &sipSelf, sipType_Test, &sipCpp, sipType_std_unique_ptr_0100AnObject, &a0, SIP_NULLPTR))
        {
          // sipCpp->setObject(*a0); // generated code, doesn't work, we need to move
	  sipCpp->setObject(std::move(*a0));

            Py_INCREF(Py_None);
            return Py_None;
        }
    }
...
}

Could it be supported by SIP ?

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions