简体   繁体   中英

std::back_insert_iterator in C++17

As shown here std::back_insert_iterator in pre- C++17 inherits from std::iterator while it doesn't in C++17. What is the reason for this change?

std::iterator is a convenience. It provides a handful of typedefs that code that uses iterators find useful. The preferred mechanism these days is std::iterator_traits , which is more flexible.

When an iterator is, in fact, a pointer it can't inherit from std::iterator , so iterator_traits has always been the way to get those typedefs. Having the typedefs in iterator types that are classes but not in iterator types that are pointers means that generic code can't use those members. Having them is minimally useful, and they're going away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM