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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With