std::back_i...ert_iterator(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… NAME

std::back_insert_iterator::back_insert_iterator β€” bestie, it's the constructor of std::back_insert_iterator, and yes the name really does just say itself twice like that. Iconic of it.

Coming at you from the C++ Standard Libary manual (yes that's how it's spelled on the tin, we don't fix it, we respect it 🫢).

✨ Synopsis ✨

explicit back_insert_iterator( Container& c );            (until C++20)
constexpr explicit back_insert_iterator( Container& c );  (since C++20)

So what does it actually do? It initializes the underlying pointer to the container to std::addressof(c). That's it. That's the whole personality. ✨


πŸŽ€ Parameters πŸŽ€

  • c β€” the container you're initializing the inserter with. Your main character container, if you will.

πŸ¦‹ Defect reports πŸ¦‹

Okay so real talk β€” the following behavior-changing defect reports were applied retroactively to previously published C++ standards. Like, they went back and edited the canon. History was rewritten, no cap.

  • DR: P2325R3
  • Applied to: C++20
  • Behavior as published: default constructor was provided as along with the requirement iterators must be default_initializable
  • Correct behavior: removed

So yeah, the default constructor got removed πŸ’€. It's giving "we're so sorry for the confusion."


🌸 Sign-off 🌸

This little gem lives over at http://cppreference.com, version 2024.06.10, and it's filed under std::back_i...ert_iterator(3) β€” yes the title is truncated with ellipsis in the corner of the page, we don't know why either, it's just the vibe πŸ’…πŸ’– mwah, go construct something cute πŸŽ€βœ¨

πŸ“¦ where this page comes from