Disparity between the std::deque and std::vector range constructors

108 Views Asked by At

This doesn't generate any warning at all and works as expected.

vector<float> vec_2(1024, -3.0f);   
vector<float> vec_3(vec_2.begin(), vec_2.end());

This, however, generates C26486 "Don't pass a pointer that may be invalid as a parameter to a function." warning. But still works.

deque<float> deque_2(1024, -3.0f);
deque<float> deque_3(deque_2.begin(), deque_2.end());

And I kinda get why the IDE would try to warn me about the implications of passing a pointer to an element of a non-contiguous container like deque. What I don't get is what's the point of this warning in this case in particular. deque_2.begin() will always return an iterator referencing the front-most element of the deque, deque_2.end() is pretty well-defined in its behavior as well.

What am I missing?

EDIT: I'm using Visual Studio 2019 with MSVC

0

There are 0 best solutions below