Why does C++ not have a trim function for strings? Why are we expected to write our own? Is there a reason that this hasn't been added in 2020?
Asked
Active
Viewed 54 times
2
-
the methods to trim strings do exist. They are called `erase` and `find_first_not_of` and `find_first_last_not_of`. See here: https://stackoverflow.com/a/25829233/4117728 – 463035818_is_not_an_ai May 19 '21 at 13:54
-
And for advice on how to best implement it, refer to [What's the best way to trim std::string?](https://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring) – Sander De Dycker May 19 '21 at 13:57
-
Why would it be added in 2020, as opposed to earlier/later? Was there a proposal submitted for C++20 that was rejected? – rustyx May 19 '21 at 14:01
-
1There are some frustrating shortcomings with Standard, and lack of trim function is just one of them. You can try writing a proposal for this :) – SergeyA May 19 '21 at 14:03