Reputation: 68366
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
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
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