Homunculus Reticulli
Homunculus Reticulli

Reputation: 68366

SWIG C++ to Python: Warning(362): operator= ignored

I am exporting a C++ class to Python and I noticed that during compilation, SWIG issued the following warning:

Warning(362): operator= ignored

I am not sure why the operator is being overloaded, because it says in the SWIG documentation, that SWIG is capable of handling operators such as the assignment operator

There is nothing special about my class, it is declared like this:

class Foo
{
public:
    Foo();
    Foo& operator= (const Foo&); 
    // etc ..
};

Why is SWIG failing to generate wrapper code for the assignment operator, and how may I fix this?

Upvotes: 12

Views: 3244

Answers (2)

Mark Tolonen
Mark Tolonen

Reputation: 177406

Read the last line of your documentation link (section 31.3.11):

Also, be aware that certain operators don't map cleanly to Python. For instance, overloaded assignment operators don't map to Python semantics and will be ignored.

Upvotes: 9

Daniel
Daniel

Reputation: 31559

There is no assignment in python (other than in primitive types), only assignment of pointers. If you want to create a copy, you need a special copy function.

Upvotes: 9

Related Questions