Tag: vector
All the articles with the tag "vector".
-
push_back vs emplace_back in C++: What's the Real Difference?
Understand push_back vs emplace_back in C++ with working examples. See exactly when emplace_back avoids a copy, when it does not, and which one to use.
-
C++ Pass Vector to Function: By Reference, Value, or Const
Learn how to pass a vector to a function in C++ by value, by reference, and by const reference. Understand copies vs references and which to use, with examples.
-
C++ Sort Vector of Structs: By Field with std::sort
Learn how to sort a vector of structs in C++ using std::sort with a lambda comparator. Sort by any field, ascending or descending, and by multiple keys.
-
C++ STL Containers: Choosing the Right One
Learn which C++ STL container to use and when. Covers vector, list, map, set, unordered_map and more with comparisons, complexity, and real-world examples.