C++11 has implemented data()
member function on std::vector
, which gives you a pointer to the memory array. Does this mean the template specialization std::vector<bool>
have this member as well? Since this specialization doesn't store the data in terms of bool *
, what kind of behavior can you expect from calling data()
?
This page documenting the class explicitely indicates that the specialization does not provide this method.
The specialization has the same member functions as the unspecialized vector, except data, emplace, and emplace_back, that are not present in this specialization.
This other page as well as §23.3.7 of the C++ specifications do confirm it.
while (myfile.good())
example on this page. Novice programmers are using this bad practice as I type this. –
Evanescent It won't compile, unless your implementation has a non-standard extension. The specialisation of std::vector<bool>
, as specified in C++11 23.3.7/1, doesn't declare a data
member.
gcc
error that I get is that data
is a "void value not ignored as it should be", which implies that the function is implemented, but has a void
return type. Which is curious. –
Wiener data()
to the generic vector
template). –
Aestival This page documenting the class explicitely indicates that the specialization does not provide this method.
The specialization has the same member functions as the unspecialized vector, except data, emplace, and emplace_back, that are not present in this specialization.
This other page as well as §23.3.7 of the C++ specifications do confirm it.
while (myfile.good())
example on this page. Novice programmers are using this bad practice as I type this. –
Evanescent No. Per std::vector<bool>
Does not necessarily store its data in a single contiguous chunk of memory.
There is no data()
member.
Well, there is no std::vector<bool>::data
, so what you can expect is a compile error.
© 2022 - 2024 — McMap. All rights reserved.