开发者

Do all Standard C++ features work in C++/CLI? [duplicate]

开发者 https://www.devze.com 2022-12-09 03:27 出处:网络
This question already has answers here: Is C++ CLI a superset of C++? (6 answers) Closed 7 years ago. If I just include existing Standard C++ class in C++/CLI program, will it work?
This question already has answers here: Is C++ CLI a superset of C++? (6 answers) Closed 7 years ago.

If I just include existing Standard C++ class in C++/CLI program, will it work?

In my tests everything worked pretty good, but is it true for every progr开发者_开发知识库am?


If you actually change the class to be a managed (gc) class, then no, it will sometimes break. In particular, the semantics of the delete operator is changed, as the objects are now managed by the garbage collector; deleting an object might not release any memory.


That is what Microsoft promises, yes. (I watched this video yesterday, in which they explicitly mentioned this -- specifically because the addition of nullptr in C++0x would compromise it)

So yeah, if you take a native C++ program and compile it as C++/CLI, with no code changes, then yes, it will still work.

And of course, if you change your code (gcnew instead of new and other "managed" changes, then of course, all bets are off, and you might or might not break the code)

0

精彩评论

暂无评论...
验证码 换一张
取 消