mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
parent
7cfb1d7961
commit
7e5019378b
|
@ -1,6 +1,6 @@
|
|||
# <a name="main"></a>C++ Core Guidelines
|
||||
|
||||
December 26, 2017
|
||||
Janualy 1, 2018
|
||||
|
||||
|
||||
Editors:
|
||||
|
@ -18558,6 +18558,13 @@ For a variable-length array, use `std::vector`, which additionally can change it
|
|||
|
||||
Use `gsl::span` for non-owning references into a container.
|
||||
|
||||
##### Note
|
||||
|
||||
Comparing the performance of a fixed-sized array allocated on the stack against a `vector` with its elements on the free store is bogus.
|
||||
You could just as well compare a `std::array` on the stack against the result of a `malloc()` accessed through a pointer.
|
||||
For most code, even the difference between stack allocation and free-store allocation doesn't matter, but the convenieance and safety of `vector` does.
|
||||
People working with code for which that difference matters are quite capable of choosing between `array` and `vector`.
|
||||
|
||||
##### Enforcement
|
||||
|
||||
* Flag declaration of a C array inside a function or class that also declares an STL container (to avoid excessive noisy warnings on legacy non-STL code). To fix: At least change the C array to a `std::array`.
|
||||
|
|
Loading…
Reference in New Issue
Block a user