5 ms·
The classic iterator categories (input, output, ...) discussed in this article have been deprecated in C++20, and replaced with new concepts. I would expect a p
by quietbritishjim 6y ago
The classic iterator categories (input, output, ...) discussed in this article have been deprecated in C++20, and replaced with new concepts. I would expect a post from 2020 claiming to be about iterators "in modern C++" to be specifically about that change, but actually it's just about the legacy categories, so this is a pretty worthless article.
- cma 6y agoIt is mentioned in the article early on: "The first thing to do is to assign the iterator some properties. Until C++17 this is done by tagging it with the tag dispatch mechanism, while C++20 uses concepts: in this article I will follow the traditional approach."
- DoofusOfDeath 6y agoHonest question: what does it mean for something to be "deprecated" in (specifically) the c++ language spec?
- millstone 6y agoThe spec itself defines it as: Normative for the current edition of the Standard, but having been identified as a candidate for removal from future revisions This is a very blunt tool. In practice, a feature may be deprecated if it is: 1. Legacy inherited from C that serves no modern purpose. The register keyword. 2. Features hardly anybody implemented. Exported templates is the only example I am aware of. Like falling off the edge of the map. 3. Features that proved to be a bad idea, like incrementing a bool. 4. Features that proved to be wholly inadequate, like codecvt for dealing with Unicode. 5. Features that are reasonably new in C++ but obviated by new stuff. You don't need std::bind if you have lambdas. This is my outsider's perspective; please chime in if you have standards committee insight.
- DoofusOfDeath 6y agoThanks for the explanation. Given my impression that the standards committee places very strong emphasis on backwards compatibility, I didn't expect there to be a policy to allow for breaking changes.
- ncmncm 6y agostrstream was adopted into C++98 with conflicting implementations, so was deprecated at the outset. You are warned not to use the conflicting parts in code meant to be portable. strstream has not been removed, yet, because spanstream is not in yet. Until that is in, there are certain things only strstream can do: specifically, attach to an existing buffer you need to parse things out of, or to format things into.
- pjmlp 6y agoOn the contrary, this article can be used by the audience in almost any modern C++ compiler out there. An article using C++20 will just lead to frustration, as there are still rough edges using concepts, with a standard that was just published last week.
- quietbritishjim 6y agoSure, this is the technique that you want to use for programs that you write today. But given that it's using the iterator concepts that have existed for decades, that will be deprecated soon if not now, why claim it's "modern C++"? The only thing I could see in the whole article that wouldn't work in C++98 was range-based for loops. At least they didn't use std::iterator, which was deprecated in C++17. The title is misleading marketing: It gives the impression you need this nice new blog post instead of all the old out of date ones, and that it's all you'll need to know for the foreseeable future.
- pjmlp 6y agoWell, regarding "modern C++", I have seen that moniker applied to even language features that were already available in pre-ISO C++98, like RAII, or type safe collections. Apparently too many people still keep using C++ compilers to compile C code, not surprising when there are schools still using Turbo C++ for MS-DOS as teaching tool, as per one of Bjarne talks. Back to C++20, C++ is no longer my main tool, but I still follow up on it and one of my hobbies is checking new standard features, hardly everything works at is supposed to be and I expect the usual three years for stabilization, so when C++23 will be around the corner, is when I expect all major compilers to fully support C++20 without triggering some kind of compiler error.
- gpderetta 6y ago> regarding "modern C++", I have seen that moniker applied to even language features that were already available in pre-ISO C++98, like RAII, or type safe collections. That's not surprising as modern C++ predates C++11. Newer standards "merely" make it more convenient to practice it. At the end of the day, modern c++ is really about emphasizing value types, RAII and parametric polymorphism as opposed to OOP. Anyway, these days we have it good conformance to new standards comes relatively quickly. It took forever for most compilers to be C+98 conformant (and technically most never reached it).
- rualca 6y ago> I would expect a post from 2020 claiming to be about iterators "in modern C++" to be specifically about that change (...) ...and yet here I am, still struggling to get some of my employer's C++ projects to build with C++14.
- deleted 6y ago[deleted]