If I e.g. have a vector v, is it ok by the standard to call:
void setData(const uint8_t* p, size_t s) {
v.assign(p, p+s);
}
setData(nullptr, 0);
In general is it always ok to call STL functions XXX(InputIterator first, InputIterator last)
as above when distance(first,last) == 0
?
In addition to what Potatoswatter stated, C++ also made the expression
nullptr + 0
valid. This wasn't the case in C.Yes. It's OK to copy the
nullptr
value to another pointer object, and that's all the implementation could possibly do. It's already forbidden to go past the end (defined here by beginning == end) or dereference it.