填充std :: deque <std :: vector <std :: string>&gt;使用boost :: assign :: list_of </std :: vector <std :: string>

时间:2012-11-15 15:31:26

标签: c++ boost c++98

是否可以初始化类型的对象:

std::deque<std::vector<std::string>>

通过boost :: assign :: list_of

1 个答案:

答案 0 :(得分:1)

尝试以下方法:

#include <boost/assign/list_of.hpp>
#include <deque>
#include <vector>
#include <iostream>
#include <string>

int main()
{
    std::deque<std::vector<std::string> > v =
        boost::assign::list_of
            (boost::assign::list_of("a")("b"))
            (boost::assign::list_of("c")("d"));

    std::cout << v[0][0] << "\n" <<
                 v[1][1] << "\n";
}

这是用最老的编译器编译的,我有VC7,而不是C ++ 98。