Tim*_* MB 5 c++ qt containers boost
在Boost中,有一些方便的功能可以让您在一行中填充容器.
例如,list_of允许您填写类似的列表.
#include <boost/assign/list_of.hpp> // for 'list_of()'
#include <list>
std::list<int> primes = boost::assign::list_of(2)(3)(5)(7)(11);
Run Code Online (Sandbox Code Playgroud)
在我的项目中我使用Qt并且不能使用Boost.有没有一种同样方便的方法来填充Qt的容器在施工点?
Kam*_*mek 12
您可以使用QList :: operator <<
QList<int> primes = QList<int>() << 2 << 3 << 5 << 7 << 11;
Run Code Online (Sandbox Code Playgroud)
从版本4.8开始,Qt支持大多数容器的C++ 11标准初始化.
http://doc.qt.digia.com/4.8-snapshot/qt4-8-intro.html
| 归档时间: |
|
| 查看次数: |
191 次 |
| 最近记录: |