Skip to content

Instantly share code, notes, and snippets.

@mackal
Created May 21, 2019 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mackal/5a06137b03e68c78e4a0087a58e1b20a to your computer and use it in GitHub Desktop.
Save mackal/5a06137b03e68c78e4a0087a58e1b20a to your computer and use it in GitHub Desktop.
#include <iostream>
#include <unordered_map>
struct test {
int a;
int b;
};
int main()
{
std::unordered_map<int, test> v;
auto &t = v[1];
t.a = 1;
t.b = 2;
auto &u = v[2];
u.a = 3;
u.b = 4;
for (auto &&t : v)
std::cout << t.second.a << " " << t.second.b << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment