Using STL/Boost to initialize a hard-coded set >

后端 未结 2 752
北海茫月
北海茫月 2020-12-19 17:59

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

相关标签:
2条回答
  • 2020-12-19 18:20

    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}};
    
    }
    
    0 讨论(0)
  • 2020-12-19 18:28
    #include <boost/assign/list_of.hpp> 
    #include <vector>
    #include <set>
    
    using namespace std;
    using namespace boost::assign;
    
    int main()
    {
        set<vector<int> > A;
    
        A = list_of
            (list_of(0)(0)(1))
            (list_of(0)(1)(0))
            (list_of(1)(0)(0));
            (list_of(0)(0)(0));
        return 0;
    }
    
    0 讨论(0)
提交回复
热议问题