c++ - Restrict string length to be in specific range -


this problems seems common issue, yet unable find solution it. , i'm convinced functionality should part of boost or other popular library.

i want have drop-in replacement std::string specify minimal , maximal length, preferably @ compile time. optionally, support state no string set (in boost::optional way). this:

ranged_string<min, max> str; 

when assigning invalid value, exception should thrown.

creating such utility myself shouldn't hard (just overloads , exception throws), don't want reinvent wheel.

it may best bet extend (or wrap) string , overload (or protect via wrapping) of operations detract or add string bounds checking. curious though, of use range-enforced string be?

edit: wouldn't @ compile time though.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -