Vector of Structures

前端 未结 6 432
悲哀的现实
悲哀的现实 2021-01-18 11:42

I have some code given to me by another person in which we have a structure

struct Pair {
    string s1;
    string s2;
    bool equivalent;
  };
         


        
6条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-18 12:12

    You can use Boost.Assign, which is a syntactic sugar for creating a vector and then populating it:

    using std::vector;
    using namespace boost::assign;
    vector v = list_of(Pair("s11", "s12", true)(Pair("s21", "s22", false));
    

提交回复
热议问题