[C++] Fix model of std::vector::size

Summary: It wasn't using code from `std::vector::empty` which recently was improved. Instead of inlining `std::vector::empty`, call it to know whether vector is empty or not.

Reviewed By: jvillard

Differential Revision: D5573379

fbshipit-source-id: e024a42
master
Andrzej Kotulski 7 years ago committed by Facebook Github Bot
parent c435ba2c76
commit 5847dd3fe9

@ -237,11 +237,11 @@ class vector {
const_reverse_iterator crend() const noexcept { return rend(); } const_reverse_iterator crend() const noexcept { return rend(); }
size_type size() const noexcept { size_type size() const noexcept {
if (beginPtr) { if (empty()) {
return 10;
}
return 0; return 0;
} }
return 10;
}
size_type capacity() const noexcept {} size_type capacity() const noexcept {}

@ -8,7 +8,7 @@
*/ */
#include <vector> #include <vector>
void foreach_access_ok(std::vector<int>& vec) { void foreach_access1_ok(std::vector<int>& vec) {
if (vec.empty()) { if (vec.empty()) {
// do nothing // do nothing
} }
@ -17,6 +17,13 @@ void foreach_access_ok(std::vector<int>& vec) {
} }
} }
void foreach_access2_ok(std::vector<int>& vec) {
int s = vec.size();
for (const auto& elem : vec) {
auto r = elem;
}
}
void iterator_for_access_ok(std::vector<int>& vec) { void iterator_for_access_ok(std::vector<int>& vec) {
if (vec.empty()) { if (vec.empty()) {
// do nothing // do nothing

Loading…
Cancel
Save