We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
<vector>
1 parent fa1448d commit c83fbfdCopy full SHA for c83fbfd
stl/inc/vector
@@ -3195,7 +3195,10 @@ public:
3195
_NODISCARD _CONSTEXPR20 size_type max_size() const noexcept {
3196
constexpr auto _Diff_max = static_cast<size_type>(_STD _Max_limit<difference_type>());
3197
const size_type _Ints_max = this->_Myvec.max_size();
3198
- if (_Ints_max > _Diff_max / _VBITS) { // max_size bound by difference_type limits
+
3199
+ // Use a const bool to avoid warning C4127 "conditional expression is constant" with Defect Report P2280R4
3200
+ const bool _Would_overflow = _Ints_max > _Diff_max / _VBITS;
3201
+ if (_Would_overflow) { // max_size bound by difference_type limits
3202
return _Diff_max;
3203
}
3204
0 commit comments