我试图将数组的一个元素设置为不同的对象。但是,编译器正在删除MyCollection
运算符。为什么这样做呢?我该如何解决它?
示例代码:
=
编译此代码段时我遇到的编译器错误是:
struct IntContainer
{
IntContainer(const int value) :
value(value)
{
}
IntContainer() :
IntContainer(0)
{
}
const int value;
};
int main(int argc, char** argv)
{
IntContainer intContainers[3];
IntContainer newIntContainer(420);
intContainers[0] = newIntContainer; // <-- Causes compiler error
return 0;
}
答案 0 :(得分:7)
编译器通常会免费为您提供<field name="inherit_id" ref="product.product_template_form_view_invoice_policy" />
和复制构造函数,但是当一个类包含2017-10-03 13:19:11,524 21646 ERROR miningsearchesuk werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 180, in run_wsgi
execute(self.server.app)
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 168, in execute
application_iter = app(environ, start_response)
File "/usr/lib/python2.7/dist-packages/odoo/service/server.py", line 249, in app
return self.app(e, s)
File "/usr/lib/python2.7/dist-packages/odoo/service/wsgi_server.py", line 184, in application
return application_unproxied(environ, start_response)
File "/usr/lib/python2.7/dist-packages/odoo/service/wsgi_server.py", line 170, in application_unproxied
result = handler(environ, start_response)
File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 1308, in __call__
return self.dispatch(environ, start_response)
File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 1282, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 591, in __call__
return self.app(environ, start_response)
File "/usr/lib/python2.7/dist-packages/odoo/http.py", line 1463, in dispatch
odoo.registry(db).check_signaling()
File "/usr/lib/python2.7/dist-packages/odoo/__init__.py", line 52, in registry
return modules.registry.Registry(database_name)
File "/usr/lib/python2.7/dist-packages/odoo/modules/registry.py", line 59, in __new__
return cls.new(db_name)
File "/usr/lib/python2.7/dist-packages/odoo/modules/registry.py", line 82, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/usr/lib/python2.7/dist-packages/odoo/modules/loading.py", line 335, in load_modules
force, status, report, loaded_modules, update_module)
File "/usr/lib/python2.7/dist-packages/odoo/modules/loading.py", line 237, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/usr/lib/python2.7/dist-packages/odoo/modules/loading.py", line 156, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "/usr/lib/python2.7/dist-packages/odoo/modules/loading.py", line 95, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/usr/lib/python2.7/dist-packages/odoo/tools/convert.py", line 845, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "/usr/lib/python2.7/dist-packages/odoo/tools/convert.py", line 915, in convert_xml_import
obj.parse(doc.getroot(), mode=mode)
File "/usr/lib/python2.7/dist-packages/odoo/tools/convert.py", line 796, in parse
self.parse(rec, mode)
File "/usr/lib/python2.7/dist-packages/odoo/tools/convert.py", line 799, in parse
self._tags[rec.tag](rec, de, mode=mode)
File "/usr/lib/python2.7/dist-packages/odoo/tools/convert.py", line 695, in _tag_record
f_val = self.id_get(f_ref)
File "/usr/lib/python2.7/dist-packages/odoo/tools/convert.py", line 782, in id_get
res = self.model_id_get(id_str, raise_if_not_found)
File "/usr/lib/python2.7/dist-packages/odoo/tools/convert.py", line 788, in model_id_get
return self.env['ir.model.data'].xmlid_to_res_model_res_id(id_str, raise_if_not_found=raise_if_not_found)
File "/usr/lib/python2.7/dist-packages/odoo/addons/base/ir/ir_model.py", line 1075, in xmlid_to_res_model_res_id
return self.xmlid_lookup(xmlid)[1:3]
File "<decorator-gen-5>", line 2, in xmlid_lookup
File "/usr/lib/python2.7/dist-packages/odoo/tools/cache.py", line 87, in lookup
value = d[key] = self.method(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/odoo/addons/base/ir/ir_model.py", line 1064, in xmlid_lookup
raise ValueError('External ID not found in the system: %s' % xmlid)
ParseError: "External ID not found in the system: product.product_template_form_view_invoice_policy" while parsing /home/dominic.pain/miningsearchesuk/src/python/msuk_sales/views/views.xml:3, near
<record model="ir.ui.view" id="view_product_template_form_inherited">
<field name="name">MSUK view product template form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view_invoice_policy"/>
<field name="arch" type="xml">
<xpath expr="//field[@name="project_id"]" position="before">
<field name="project_templates"/>
</xpath>
</field>
</record>
成员时,生成operator=
是没有意义的,因为您无法执行对const
成员的分配。
您可以编写自己的,但仍然无法为operator=
成员分配值。