std::insert...ert_iterator(3)

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

🌸 NAME 🌸

std::insert_iterator::insert_iterator β€” bestie, it's the std::insert_iterator::insert_iterator member, and yes the name really does repeat itself like that. Main character energy πŸ’…βœ¨

πŸ“œ Synopsis πŸ“œ

This is from the C++ Standard Libary manual (that spelling is literally in the source, no cap 😭).

Until C++20, the signature is giving:

insert_iterator( Container& c, typename Container::iterator i );

(until C++20)

Since C++20, it's serving constexpr:

constexpr insert_iterator( Container& c,
ranges::iterator_t<Container> i );

(since C++20)

Lowkey the important bit: it initializes the underlying pointer to the container to std::addressof(c) and the underlying iterator to i 🫢✨

πŸŽ€ Parameters πŸŽ€

  • c β€” container to initialize the inserter with πŸ’–
  • i β€” iterator to initialize the inserter with 🌸

πŸ’… Defect reports πŸ’…

The following behavior-changing defect reports were applied retroactively to previously published C++ standards. Retroactive glow-ups, we love to see it 😭🌈

  • LWG 561 β€” applied to C++98. Behavior as published: the type of i was independent of Container. Correct behavior: it is the iterator type of Container ✨
  • P2325R3 β€” applied to C++20. Behavior as published: default constructor was provided as along with the iterators must be default_initializable requirement. Correct behavior: C++20 removed the requirement πŸ’€

Okay that's the whole page, bestie 🫢 Source/version: http://cppreference.com; date: 2024.06.10; page: std::insert...ert_iterator(3). Slay and stay constexpr βœ¨πŸ’…

πŸ“¦ where this page comes from