How do I use C++ STL containers in My iPhone App?

喜你入骨 提交于 2019-12-22 04:19:34

问题


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?


回答1:


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.




回答2:


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

  • http://objectivelib.sourceforge.net/YesOpenStep/index.html


来源:https://stackoverflow.com/questions/823116/how-do-i-use-c-stl-containers-in-my-iphone-app

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