The C++ standard library containers are nice. Like, really nice. As the kind of person who worries about performance to the point that they were shy of anything other than a raw data array I've come to appreciate the usability (and speed!) of ye olde std::vector
. Does that many me sound like a wannabe oldie?
Recently I came across a situation where I had, say, a vector [a, b, c, d]
and wanted to create the vectors [a, b, c]
, [a, b, d]
, [a, c, d]
, and [b, c, d]
. I didn't want to actually allocate O(N(N-1))
additional memory but learned that std::vector
didn't support holding references. That's when I came across std::reference_wrapper
.
From the Cppreference page: