Skip to content

Commit

Permalink
expand rvalue insertion example
Browse files Browse the repository at this point in the history
  • Loading branch information
greg7mdp committed Oct 28, 2018
1 parent f130f99 commit 9a459dd
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions examples/insert_rvalue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,29 @@ int main()
#endif

AssociativeContainer c;
char buf[10];
char buf[10], buf2[10];

for (int i=0; i<100; ++i)
for (int i=0; i<10; ++i)
{
sprintf(buf, "%d", i);
sprintf(buf, "%d", i);
sprintf(buf2, "val%d", i);
auto& value = c[make_unique<std::string>(buf)];
sprintf(buf, "val%d", i);
value = make_unique<std::string>(buf);
value = make_unique<std::string>(buf2);
}

for (int i=10; i<20; ++i)
{
sprintf(buf, "%d", i);
sprintf(buf2, "val%d", i);
auto&& p = std::make_pair(make_unique<std::string>(buf), make_unique<std::string>(buf2));
c.insert(std::move(p));
}

for (int i=20; i<30; ++i)
{
sprintf(buf, "%d", i);
sprintf(buf2, "val%d", i);
c.emplace(std::make_pair(make_unique<std::string>(buf), make_unique<std::string>(buf2)));
}

for (auto& p : c)
Expand Down

0 comments on commit 9a459dd

Please sign in to comment.