About 51 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 …

  2. Delete all items from a c++ std::vector - Stack Overflow

    Delete all items from a c++ std::vector Asked 16 years, 2 months ago Modified 5 years, 6 months ago Viewed 144k times

  3. c++ - What is the easiest way to initialize a std::vector with ...

    Feb 10, 2010 · A more recent duplicate question has this answer by Viktor Sehr. For me, it is compact, visually appealing (looks like you are 'shoving' the values in), doesn't require C++11 …

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

    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 …

  5. 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 …

  6. 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 …

  7. 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 …

  8. 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 …

  9. Efficient way to return a std::vector in c++ - Stack Overflow

    How much data is copied, when returning a std::vector in a function and how big an optimization will it be to place the std::vector in free-store (on the heap) and return a pointer instead i.e. is:...

  10. Is std::vector so much slower than plain arrays? - Stack Overflow

    Sep 8, 2010 · And since the question was about std::vector then yes it is !much! slower than plain arrays (optimized/unoptimized). But when you're doing a benchmark, you naturally want to …