Home >Backend Development >C++ >What's the Best Alternative to `std::vector` for C-Style Array Access in C ?
The vector
For C-Array Functionality:
For Random Access without C-Array Functionality:
Implementation Details:
If the c_array() functionality is necessary and dynamic sizing is required, consider the following implementation:
struct my_bool { bool the_bool; }; typedef vector<my_bool> my_bool_vector;
While this approach requires the use of an intermediate my_bool structure for direct access to the underlying array, it provides the desired C-style array capability.
The above is the detailed content of What's the Best Alternative to `std::vector` for C-Style Array Access in C ?. For more information, please follow other related articles on the PHP Chinese website!