vector cplusplus reference
终极管理员 知识笔记 148阅读
What is vector in C++?

答:1) std::vector is a sequence container that encapsulates dynamic size arrays. The elements are stored contiguously, which means that elements can be accessed not only through iterators, but also using offsets to regular pointers to elements.
Is it possible to constexpr a vector in C++?

答:Member functions of std::vector are constexpr: it is possible to create and use std::vector objects in the evaluation of a constant expression. However, std::vector objects generally cannot be constexpr, because any dynamically allocated storage must be released in the same evaluation of constant expression. (since C++20)
What is the difference between vector and PMR in C++?

答:1) std::vector is a sequence container that encapsulates dynamic size arrays. 2) std::pmr::vector is an alias template that uses a polymorphic allocator.
How do you access an element in a vector?

答:The elements are stored contiguously, which means that elements can be accessed not only through iterators, but also using offsets to regular pointers to elements. This means that a pointer to an element of a vector may be passed to any function that expects a pointer to an element of an array.