.. include:: Screenplay: Inserting Elements ============================== .. contents:: :local: Subscript Operator ------------------ .. literalinclude:: code/map-insert-subscript.cpp :language: c++ :caption: :download:`code/map-insert-subscript.cpp` ``insert()`` ------------ * Takes a pair ``(key, value)`` * Returns a pair ``(iterator, bool)`` * Good old pre C++11 way of handling all that .. literalinclude:: code/map-insert-insert-pre11.cpp :language: c++ :caption: :download:`code/map-insert-insert-pre11.cpp` * Same, using :doc:`C++11 auto ` .. literalinclude:: code/map-insert-insert-auto.cpp :language: c++ :caption: :download:`code/map-insert-insert-auto.cpp` * Same, using :doc:`C++17 Structured Binding ` .. literalinclude:: code/map-insert-insert-structured-binding.cpp :language: c++ :caption: :download:`code/map-insert-insert-structured-binding.cpp`