4 ms·
Making Your Own Container Compatible with C++20 Ranges
- monocasa 6y agoThis kind of thing is easily one of my favorite pieces of C++. I used to be the OS lead for a proprietary C++14 RTOS, and being able to build our own intrusive collections libraries that were able to use all the same syntax sugar as the STL was absolutely killer. IMO, all systems languages should be expressive enough to implement their standard libraries and containers as normal language code, but sadly that isn't always the case.
- slavik81 6y ago> One of my fundamental aims for C++ is (from the very start in 1979) to provide equally good support for user-defined and built-in types. For example, I’d like to be able to build an integer type that is as good as the built-in int in every way (with the possible exception of compile time). ~ Bjarne Stroustrup, How can you be so certain? (2019)
- pjmlp 6y agoWhich made me an early adopter in 1993 for MS-DOS, as C already felt primitive back then. However I still dream of the day where static analysis can fix all possible security issues.
- nicoburns 6y agoWhich systems languages can't do this?
- rfoo 6y agoThe only one I'm aware of is Golang.
- nly 6y agoI'm not sure if this situation has improved in C++20, but writing iterator types properly in classic C++ really sucks, and this article glosses over a lot of the details. I've always used Boosts iterator_facade to do this: https://www.boost.org/doc/libs/1_75_0/libs/iterator/doc/iterator_facade.html#implementing-the-core-operations https://www.boost.org/doc/libs/1_75_0/libs/iterator/doc/iter... , which requires you only implement a maximum of 6 functions for any iterator type.
- ubadair 6y agoBoost.STLInterfaces provides a more modern alternative to iterator_facade. https://www.boost.org/doc/libs/1_75_0/doc/html/stl_interfaces.html https://www.boost.org/doc/libs/1_75_0/doc/html/stl_interface...
- deleted 6y ago[deleted]
- fefe23 6y agoI find it pretty funny that the article opens with "so we don't need all that SFINAE junk anymore" and then proceeds to spend pages upon pages explaining the other junk we need in its place :-) I know, apples to oranges, the SFINAE bit was about concepts, not iterators. Still, pretty funny.