如何使用 C++ 我的 iPhone 应用程序中的 STL 容器?
我想在我的 iPhone 应用程序中使用 STL 集(它是在 XCode 中用 Objective-C 编写的)。 如何包含设置和/或使用标准命名空间?
在 C++ 中我会这样做:
#include<set>
using namespace std;
// use the set<T> somewhere down here...
How can I do this in Objective-C?
I'd like to use an STL set in my iPhone app (which is written in Objective-C in XCode). How do I include set and/or use the standard namespace?
In C++ I'd do this:
#include<set>
using namespace std;
// use the set<T> somewhere down here...
How can I do this in Objective-C?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需重命名源文件,使其以 .mm 结尾,它就会触发 Objective-C++ 前端; 然后你可以在其中混合 Objective-C 和 C++。 更多信息请参见此处。
Just rename your source file so it ends in .mm and it should trigger the Objective-C++ front-end; you can then mix Objective-C and C++ in it. More information here.
Objective-C 不直接支持 STL。 不过似乎有几个项目正在尝试将 STL 移植到 Objective-C。 Objectivelib 就是其中之一,可以在 sourceforge
STL is not directly supported in objective-C. There appear to be several projects though that are attempting to port STL to objective-C. Objectivelib is one such and is available on sourceforge