4 ms·
While "easy" is rather subjective, I would say this: if you already know the basics of the standard library, then this is indeed quite easy. For the most part,
by rleigh 10y ago
While "easy" is rather subjective, I would say this: if you already know the basics of the standard library, then this is indeed quite easy. For the most part, it's not even remotely modern.
- it's a simple templated function; could even be reduced to one parameter if you use "typename Container::value_type" for Value
- it's using find (standard library algorithm)
- it's using begin and end (iterators common to all standard library containers)
- it's using emplace_back (new to C++11 with rvalue refs, but everyone already knows push_back which it replaces)
While emplace_back might be new to people using C++98, everything else is well over two decades old. It's extensively documented, and if you've ever done anything with the standard library, it's basic stuff. If any C++ programmer struggles to understand this, then they are essentially stating that they don't know the basics of the standard library or the language.