SWIG C ++到Python:警告(362):operator =被忽略 [英] SWIG C++ to Python: Warning(362): operator= ignored
问题描述
我正在导出一个C ++类到Python,我注意到在编译期间,SWIG发出以下警告:
I am exporting a C++ class to Python and I noticed that during compilation, SWIG issued the following warning:
Warning(362): operator= ignored
我不知道为什么操作符被重载, SWIG文档,SWIG能够处理诸如作业之类的操作符
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 ..
};
为什么SWIG无法为赋值运算符生成包装代码, / p>
Why is SWIG failing to generate wrapper code for the assignment operator, and how may I fix this?
推荐答案
在python中没有赋值(除了原始类型),只有指针的赋值。如果您要创建副本,则需要一个特殊的复制功能。
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.
这篇关于SWIG C ++到Python:警告(362):operator =被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!