Daily bit(e) of C++ | std::front_inserter, std::back_inserter, std::inserter
Preallocating capacity for elements is generally the performance-optimal approach. However, it adds code complexity, and we might not know the number of elements upfront.
Inserter adapters solve this problem by adapting the destination range and calling push_back (back_inserter), push_front (front_inserter) or insert (inserter) on each write.
ncG1vNJzZmirmaK8r8DOrZ9nq6WXwLWtwqRlnKedZL1wsMCio7Jlkp7BpnnOn2ScZaOpsae%2BzqermKGeqLKzwMSr
Filiberto Hargett
Update: 2024-12-02