Store different data types in map - with info on type

前端 未结 3 1641
难免孤独
难免孤独 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:13

    You can implement a multi-type map by leveraging the nifty features of std::tuple in C++11, which allows access by a type key. You can wrap this to create access by arbitrary keys. An in-depth explanation of this (and quite an interesting read) is available here:

    https://jguegant.github.io/blogs/tech/thread-safe-multi-type-map.html

    The modern C++ features provide create ways to solve old problems.

提交回复
热议问题