Add missing Mandates for resize_and_overwrite by frederick-vs-ja · Pull Request #5695 · microsoft/STL (original) (raw)

Currently, MSVC STL hasn't implemented the Mandates in [string.capacity]/8:

Mandates: OP has an integer-like type ([iterator.concept.winc]).

As a result, the following ill-formed program is accepted (Godbolt link):

#include #include

int main() { std::string{}.resize_and_overwrite(0, [](const char*, std::size_t) { struct NotIntegerLike { operator std::size_t() const { return 0; } }; return NotIntegerLike{}; }); }

This PR adds the missing static_assert and expands coverage for GH-2524 to all supported (cv-unqualified) integer-like types.