C++11于Android NDK它已被支持,本文介绍了如何NDK添加C++11支持标准。
在开源项目Cocos2d-x于,他已经加入C++11支持标准。
1.改动Application.mk文件,加入NDK_TOOLCHAIN_VERSION
NDK_TOOLCHAIN_VERSION=4.8
2.加入APP_CPPFLAGS,在命令行编辑时支持C++11
APP_CPPFLAGS := -frtti -std=c++11
然后编写測试函数。在JNI中调用此函数就可以。
#include
#include
#include
using namespace::std;
#define LOG_TAG "cachetest"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
template
class MyArray
{
private:
vector m_Array;
public:
MyArray() { }
MyArray(const initializer_list& il)
{
// Manually populate the elements of the array from initializer_list x
for (auto x: il){ // use range-based for statement to iterate over the el