使用STL /升压初始化硬件codeD集&LT;矢量&lt;&INT GT; &GT; [英] Using STL/Boost to initialize a hard-coded set<vector<int> >
问题描述
筛选<一个href=\"http://stackoverflow.com/questions/2236197/c-easiest-way-to-initialize-an-stl-vector-with-hard$c$cd-elements\"标题=问题>问题已经问过,我想用STL这些元素都在可能的最干净的方式硬codeD来初始化的容器。在这种情况下,元件是一个双重嵌套容器
Like this question already asked, I'd like to initialize a container using STL where the elements are hard-coded in the cleanest manner possible. In this case, the elements are a doubly nested container:
set<vector<int> > A;
和我想(例如)将以下值:
And I'd like (for example) to put the following values in:
A = [[0,0,1],[0,1,0],[1,0,0],[0,0,0]];
C ++ 0x的罚款,使用 G ++
4.4.1。 STL是preferable因为我不使用升压为code的任何其他部分(虽然我不介意与它的一个例子!)。
C++0x fine, using g++
4.4.1. STL is preferable as I don't use Boost for any other parts of the code (though I wouldn't mind an example with it!).
推荐答案
这确实使用G ++ 4.4.1,与-std =的C ++ 0x
This does use g++ 4.4.1, with -std=c++0x
#include <set>
#include <vector>
using namespace std;
int main()
{
set<vector<int>> A = {{0,0,1},{0,1,0},{1,0,0},{0,0,0}};
}
这篇关于使用STL /升压初始化硬件codeD集&LT;矢量&lt;&INT GT; &GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!