News for hackers. Stuff that matters.
Re:Manipulating C++ Containers Functionally by Aardwolf on Sunday December 16, 2012 @05:03PM (#4929745)
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 :)

Re:Manipulating C++ Containers Functionally by akaus on Monday December 17, 2012 @01:38AM (#4931096)
There is STO library: 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

Re:Manipulating C++ Containers Functionally by zainny on Sunday December 16, 2012 @06:48PM (#4930076)
Fortunately 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
Re:Manipulating C++ Containers Functionally by splinterofchaos on Sunday December 16, 2012 @06:56PM (#4930112)
Technically, 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_stri...