Home > Backend Development > C++ > Can You Create a `std::vector` in C 11?

Can You Create a `std::vector` in C 11?

Patricia Arquette
Release: 2024-12-27 01:44:08
Original
435 people have browsed it

Can You Create a `std::vector` in C  11?

Is Vector Permissible in C 11?

C standards have undergone revisions over time, notably from C 03 to C 11, leading to stricter requirements for each container operation. This allows for the inclusion of types that are copy-constructible but not assignable, such as structures with const members, in vectors as long as specific operations are performed (e.g., construction and push_back).

The inquiry arises as to whether this relaxation in standards allows for the creation of vector in C 11. However, this is not the case. The allocator requirements mandate that T be a "non-const, non-reference object type."

The inability to do much with a vector of constant objects, as well as the near equivalence of a const vector, further disincentivizes the creation of vector.

The C standards over the years have continuously refined this aspect, from explicitly barring any type in C 03 to excluding even const and volatile object types in C 17.

The above is the detailed content of Can You Create a `std::vector` in C 11?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template