6 ms·
Converting a number to a string: std::to_string() available since C++11. Sorting a container will be sort(container) with the Range V3 proposal which is getting
by mattnewport 8y ago
Converting a number to a string: std::to_string() available since C++11. Sorting a container will be sort(container) with the Range V3 proposal which is getting close to standardization. C++20 introduces a contains() member for map and set.
- Aardwolf 8y agoCool! Been using C++11 for so long now and never knew about std::to_string. Heard about the ranges many times already, I think they got some delays. What's wrong with functions in the standard library that simply take a container and call .begin() and .end() inside of them though? No such complex thing as ranges needed for that. Contains sounds nice, didn't know about that one yet either. Thanks for the info :)
- mattnewport 8y agoIt's looking likely that ranges will make it into C++20 according to the author of the proposal Eric Niebler: "The entirety of the Ranges TS with the addition of lazy adaptor pipelines is now all but certain to be in C++20." https://mobile.twitter.com/ericniebler/status/1005413279781609473 https://mobile.twitter.com/ericniebler/status/10054132797816...
- fourthark 8y agoMy understanding is that ranges are pretty simple to use, a nice generalization and cleaning up of STL. Pretty much just follows through on all the implications of "functions that simply take a container and call begin and end on them". The implementation I'm sure is complex though.
- Karliss 8y agoRange proposal has been there for a long time unfortunately it got defined using concepts mechanism http://en.cppreference.com/w/cpp/language/constraints http://en.cppreference.com/w/cpp/language/constraints . Concepts is a lot more complicated change. This mostly affects wording in standardese text and potentially quality of compiler errors. It could be possible to have ranges without concepts but that would require rewriting most of the proposal. There is even an existing implementation which is c++11 compatible.
- CJefferson 8y agoTrue, although a closer comparison might be we still cant print, to_string or std::hash a vector<int>.
- mattnewport 8y agoThe ranges proposal should make it possible to do all of those fairly elegantly too.
- CJefferson 8y agoI hope so, but they should really both have been in C++11, so that's going to be about 10 years waiting for them.