Is it "legal" to increment the end
iterator of a std::string
in order to include the null-terminator in the range?
For example
std::string my_text{"Arbitrary string"};
std::vector<std::uint8_t> my_collection{};
my_collection.insert(my_collection.end(), std::begin(my_text), std::next(std::end(my_text)));
The reason I ask is that I'd just prefer to avoid the pointer arithmetic involved in my_text.c_str() + my_text.size()
(or is it my_text.size()+1
?).
I'm reasonably confident that most implementations today would behave as expected. Still, answers which include C++-legalese for the language lawyers among us are appreciated. Just so I have an airtight defense if I'm ever in C++ court.