Store different data types in map - with info on type

前端 未结 3 1639
难免孤独
难免孤独 2021-01-07 00:59

I need to parse and store a somewhat (but not too) complex stream and need to store the parsed result somehow. The stream essentially contains name-value pairs with v

3条回答
  •  灰色年华
    2021-01-07 01:24

    Since your data types are fixed what about something like this...

    Have something like a std::vector for each type of value. And your map would have as the second value of the pair the index to the data.

    std::vector vInt;
    std::vector vFloat;
    .
    .
    .
    
    map> Data;
    

提交回复
热议问题