How to create a list of tuples C++

后端 未结 4 923
南方客
南方客 2021-02-14 08:06

I am fairly new to c++, I dont really have any background in it. I am tying to create a list of tuples, the first will be an int, the second will be a string.

          


        
4条回答
  •  既然无缘
    2021-02-14 09:05

    Might not be relevant here, but if the "creation part" contains filling up the list with elements, Boost.Assign could be useful. You can do something like this:

    #include 
    #include 
    
    int main()
    {
        typedef boost::tuple tuple;
    
        std::vector v = boost::assign::tuple_list_of(1, "foo")(2, "bar");
    }
    

    Depending on your scenario ofcourse.

提交回复
热议问题