本文介绍了使用STL /升压初始化硬件codeD集<矢量<&INT GT; >的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
筛选问题已经问过,我想用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;
发布评论