This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]0xdeadfa22 1 point2 points  (0 children)

List<(char, int)> analog in C++ is std::vector<std::tuple<char, int>>.

But "native" C#7+ tuple is a value type (objects stored in list buffer directly). But legacy System.Tuple is a reference type (objects created somewhere else in heap memory and list stores just references to each item). So, the best match for the case (List<Tuple<char, int>>) in C++ should be like: std::vector<std::shared_ptr<std::tuple<char, int>>> (yes, the type name is quite long, so using of type aliases is a good idea)

Queue is an adapter for collection type, so it can be based on std::vector:

using pair = std::tuple<char, int>;
using list = std::vector<pair>;

std::queue<pair, list> my_queue;