About 50 results
Open links in new tab
  1. How does c++ std::vector work? - Stack Overflow

    Jul 2, 2010 · Using std::vector allows the use of other Standard Template Library components such as algorithms so using std::vector comes with quite a few advantages over a C style array as you get to …

  2. std::vector versus std::array in C++ - Stack Overflow

    Dec 12, 2010 · std::vector is a template class that encapsulate a dynamic array 1, stored in the heap, that grows and shrinks automatically if elements are added or removed. It provides all the hooks …

  3. How is C++ std::vector implemented? - Stack Overflow

    Apr 26, 2013 · I have been using std::vector a lot, and recently I asked myself this question: "How is std::vector implemented?" I had two alternatives: 1) Linked list, and then making the API feel like …

  4. When should I use a std::inplace_vector instead of a std::vector?

    Oct 29, 2024 · A std::vector (or anything else which requires dynamic allocation) is not usable within a constexpr expression. The inplace storage of std::inplace_vector allows it to be used as a constexpr …

  5. How to find out if an item is present in a std::vector?

    Feb 21, 2009 · 11 Bear in mind that, if you're going to be doing a lot of lookups, there are STL containers that are better for that. I don't know what your application is, but associative containers …

  6. c++ - What is the difference between std::array and std::vector? When ...

    What is the difference between std::array and std::vector? When do you use one over other? I have always used and considered std:vector as an C++ way of using C arrays, so what is the difference?

  7. check if a std::vector contains a certain object? [duplicate]

    Aug 10, 2010 · See question: How to find an item in a std::vector? You'll also need to ensure you've implemented a suitable operator==() for your object, if the default one isn't sufficient for a "deep" …

  8. c++ - std::vector: vec.data () or &vec [0] - Stack Overflow

    May 24, 2012 · 1 Before C++11's std::array I would say that std::vector was the most common container to be used instead of the C-style array. The [] operator usually implies constant time access, (which …

  9. c++ - What is the use of const std::vector? - Stack Overflow

    Aug 23, 2021 · By using std::vector the compiler can work that out for your dynamically. This matters in maintenance situations as it prevents errors. You only add/remove a string from the initializer of the …

  10. Copying std::vector: prefer assignment or std::copy?

    You can't, for example, use the assignment operator to copy from a std::list to a std::vector, or from one portion of a std::vector to another portion of the same std::vector.