C++11のVS2010対応状況

C++11の機能で、どこまでVS2010で対応しているか少し調べた。


以下対応しているもの。


以下対応していないもの。

  • コンテナの初期化 (vector v = {1,2,3];)
  • foreach
  • メンバー初期化子


以下、ラムダ式の例(注:MFCライブラリを使用していることに注意)。

#include "stdafx.h"
#include <vector> 
#include <algorithm>

using namespace std;

struct Person {
	int id;
	CString name;
};

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	vector<Person> v;
	Person p1 = Person();
	Person p2 = Person();
	Person p3 = Person();
	p1.id = 2;
	p1.name = "2";
	p2.id = 3;
	p2.name = "3";
	p3.id = 1;
	p3.name = "1";
	v.push_back(p1);
	v.push_back(p2);
	v.push_back(p3);
	sort(v.begin(), v.end(), [](const Person& a, const Person& b) {
		return a.name < b.name;	
	});

	for (int i = 0; i < v.size(); i++) {
		printf("%d: %s\n", v[i].id, v[i].name);
	}

	return 0;
}