的ISO C ++ code的例子是无效的C ++ / CLI [英] Examples of ISO C++ code that is not valid C++/CLI
问题描述
我已经看到了关于C ++ / CLI是否是C的一个超集++或不能在互联网上相互矛盾的答案。
I've seen contradictory answers on the internet with regard to whether C++/CLI is a superset of C++ or not.
在这个问题上声称,技术上不,但不提供非C的例子接受的答案 ++ / CLI code,符合ISO C ++。关于这个问题的另一个答案引用一本书,说的相反。
The accepted answer on this question claims that "technically no", but doesn't provide an examples of non-C++/CLI code that conforms to ISO C++. Another answer on that question cites a book that says the opposite.
所以,可以请你提供准确答案的与例如code 的失败对C ++ / CLI或引用受信任的来源(MSDN为例)在这个问题上?
So, can you please provide accurate answers with example code that fails on C++/CLI or cite a trusted source (MSDN for example) on this matter?
我有今天有人这个话题上来,以为我想告诉自己,但我没有找到任何明确的答案其他地方!
I had someone this topic come up today and thought I would like to inform myself, but I didn't find any clear answer elsewhere!
推荐答案
有效C ++的,无效的C ++ / CLI:
Valid C++, invalid C++/CLI:
int main()
{
int gcnew = 42;
}
gcnew
,通用
和 nullptr
都在C ++ / CLI保留字; nullptr
不是一个真正的问题,当然在C ++ 0x中,。 2003年引擎盖下:香草萨特博客上讲述 C ++ / CLI关键字
gcnew
, generic
, and nullptr
are all reserved words in C++/CLI; nullptr
isn't really an issue in C++0x, of course. Herb Sutter blogged about C++/CLI keywords: Under the hood in 2003.
有关它的价值,当我工作在一个大的混合codeBase类(C ++和C ++ / CLI),我从来没有碰到语法问题,或这样琐碎的问题。用C ++ / CLI(在我看来,当然)巨人的问题是,本土code和管理code具有完全不同的资源管理范式,写混code忘记它的模式时,它真的很容易你需要某些东西。我定了很多的是由于要么是管理资源确定性毁坏,或天然资源将被清理被垃圾收集器的假设错误。
For what it's worth, when I was working on a large mixed codebase (both C++ and C++/CLI), I never ran into syntax issues or trivial issues like this. The giant issue with C++/CLI (in my opinion, of course) is that native code and managed code have completely different resource management paradigms, and it's really easy when writing mixed code to forget which paradigm you need for certain things. I fixed a lot of errors that were due either to an assumption that managed resources were destroyed deterministically or that native resources would be cleaned up by the garbage collector.
这篇关于的ISO C ++ code的例子是无效的C ++ / CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!