[patch] added a _LIBCPP_ASSERT to std::string::__init( __first, __last ) to ensure [__first,__last] is valid

Hello.
Currently, std::string::string( it_first, it_last ) does not check that the range is valid, which results in a very huge memory reservation. This reservation might result in an immediate throw, but depending on OSes and/or OSes'configuration (overcommit parameters on linux *might* avoid the throw, for exemple) it could also only lead to a crash far than the source of the problem.

This patch simply adds an assertion to be sure that the range is valid (distance(last,first)>=0) when explicitly asked by the developer (therefore).

patch_string_init (2.03 KB)