-1
unordered_map<T, pair<int, T>> _sets;  

Let's say I have a key called _key, how can I access the data in the unordered_map? How can I get the data type T and int from the pair<>?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0
T myT = _sets[_key].first;
pair<int, T> myPair = _sets[_key].second;

int fromPairInt = myPair.first;
T fromPairT = myPair.second;

fast access:

 int fromPairInt = (_sets[_key].second).first;
    T fromPairT = (_sets[_key].second).second;