News for hackers. Stuff that matters.
Re:Writing a custom iterator in modern C++ by quietbritishjim on Sunday December 20, 2020 @10:45PM (#25491954)
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.
Re:Writing a custom iterator in modern C++ by pjmlp on Monday December 21, 2020 @01:56AM (#25492703)
On 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.

Re:Writing a custom iterator in modern C++ by quietbritishjim on Monday December 21, 2020 @05:03AM (#25493517)
Sure, 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.

Re:Writing a custom iterator in modern C++ by pjmlp on Monday December 21, 2020 @05:16AM (#25493582)
Well, 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.

Re:Writing a custom iterator in modern C++ by gpderetta on Monday December 21, 2020 @07:09AM (#25494156)
> 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).

Re:Writing a custom iterator in modern C++ by cma on Sunday December 20, 2020 @10:50PM (#25491975)
It 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."

Re:Writing a custom iterator in modern C++ by DoofusOfDeath on Sunday December 20, 2020 @11:16PM (#25492084)
Honest question: what does it mean for something to be "deprecated" in (specifically) the c++ language spec?
Re:Writing a custom iterator in modern C++ by millstone on Sunday December 20, 2020 @11:40PM (#25492184)
The 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.

Re:Writing a custom iterator in modern C++ by ncmncm on Monday December 21, 2020 @02:05PM (#25498210)
strstream 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.

Re:Writing a custom iterator in modern C++ by DoofusOfDeath on Monday December 21, 2020 @12:26PM (#25497090)
Thanks 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.
Re:Writing a custom iterator in modern C++ by rualca on Monday December 21, 2020 @05:01AM (#25493510)
> 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.