3 ms·
I do agree that C++'s STL is sometimes too verbose. It's important to be generic, but it'd have been great if the most common conveniences were added as well t
by Aardwolf 14y ago
I do agree that C++'s STL is sometimes too verbose.
It's important to be generic, but it'd have been great if the most common conveniences were added as well to make it pleasant to use. E.g.: erase remove idiom, count but no contains, specifying begin() and end() even when you mean the whole container, ... Anything where you need to type the variable name of your container more than once to do one operation on it.
Not just the containers and stl algorithms have that annoyance, but also the string stream operators to convert numbers to strings, this is way too verbose imho.
At least the new initializer lists make some things way more compact and convenient now :)
- zainny 14y agoFortunately with C++11 we no longer have to do the stringstream dance thanks to built-in stoi/stol string member functions: http://en.cppreference.com/w/cpp/string/basic_string/stol http://en.cppreference.com/w/cpp/string/basic_string/stol
- splinterofchaos 14y agoTechnically, those are free functions defined on strings, not members functions of the class string. But also: std::to_string http://en.cppreference.com/w/cpp/string/basic_string/to_string http://en.cppreference.com/w/cpp/string/basic_string/to_stri...
- akaus 14y agoThere is STO library: http://github.com/lvv/sto http://github.com/lvv/sto > E.g.: erase remove idiom remove sub-string: string("abcd") - "cd" > specifying begin() and end() unary '+', '-' overloaded to return to begin()/end() > when you mean the whole container, ... Euler example in just one expression (with boost lambda): range(1000) | (!(_1%3) || !(_1%3)) | add