使用STL /升压初始化硬件codeD集<矢量<&INT GT; >

编程入门 行业动态 更新时间:2024-10-10 14:29:06
本文介绍了使用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;

本文发布于:2023-11-13 10:49:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584170.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:矢量   初始化   硬件   codeD   STL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!