Does C 11 Permit vector
In C 11, container requirements have undergone significant revisions. Unlike C 03, which imposed blanket requirements on containers, C 11 specifies finely-grained requirements for each container operation.
This change allows types that are copy-constructible but not assignable—such as structures with const members—to be stored in vectors, provided that only certain operations are performed.
However, does this imply that C 11 permits vector
Answer
No. Despite similarities to structures with const members, const T is not a permissible element type according to the allocator requirements, which stipulate "non-const, non-reference object type."
Implication
Creating a vector of constant objects would be impractical, and a const vector
The above is the detailed content of Can C 11 Vectors Hold `const T` Elements?. For more information, please follow other related articles on the PHP Chinese website!