C++ Builder bccarm error when calling std::vector::push_back with TObject descendant

强颜欢笑 提交于 2019-12-01 12:24:34

To get the above code compiled the vector type has to be defined as an unsafe pointer.

TComponent* Comp = new TComponent(this);
std::vector<__unsafe TComponent*> Comps;
Comps.push_back(Comp);

I openened a support case for an other problem I had. The embarcadero support gave me the following information which I applied to this problem and it seems to work:

__unsafe tells the compiler that object lifetimes will be handled and no ARC code is generated for the objects

More about this topic:

http://docwiki.embarcadero.com/RADStudio/Berlin/en/Automatic_Reference_Counting_in_C%2B%2B#weak_and_unsafe_pointers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!