7
anolis
6y

I think vector is the coolest type in c++

Comments
  • 5
    But use it only if you really can't figure out how much memory you actually need, and even then don't use it in time critical code parts.
  • 2
    @Fast-Nop thank you for this insight, I'm still very much a noob with c/++
  • 2
    Disagree: look for shared_ptr and weak_ptr, and say goodbye to memory leaks and segfaults.
  • 2
    The coolest part of modern C++ is having regular expressions in the standard. I've waited two decades for it to happen!
    Why are people so obsessed with vector?
    If you really need continuous memory for the access speed, use array.
    If you just need a comfortable container, use list.
    There aren't that many reasons to use vector...

    ... And hash containers are much cooler! 😁
  • 1
    @FrodoSwaggins Depends. The thing that must not happen in time critical parts is putting in another element that triggers malloc behind the scenes. Not only that this can be slow, the runtime even varies a lot. But that's the one feature that discerns std::vector from std::array, not bounds checking.
  • 1
    @Yamakuzure I didn't even know about list lol
Add Comment