我想 boost::将列表分配给空值。 像这样的东西:
using namespace boost::assign;
std::list<int> myList = list_of<int>();
我想要这样做的原因是我有一个要初始化的列表映射,并且映射中的一个列表是空的。 所以我实际上想要:
std::map<int, std::list<int> > myMap =
(map_list_of(0, list_of<int>())
(1, list_of<int>(1)(2))
(3, list_of<int>(99));
最佳答案
使用std::list<int>()
而不是list_of<int>()
:
std::map<int, std::list<int> > myMap =
(map_list_of(0, std::list<int>())
(1, list_of<int>(1)(2))
(3, list_of<int>(99));
关于list - boost 分配空列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8447449/