From 243131aedbac28c623a9b55ddb36c00d7213173e Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Sun, 8 Jul 2018 22:52:41 +0200 Subject: [PATCH] document new methods of the ext map --- alib2std/src/extensions/map.hpp | 63 ++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/alib2std/src/extensions/map.hpp b/alib2std/src/extensions/map.hpp index 108f55f905..93f7cc4c5e 100644 --- a/alib2std/src/extensions/map.hpp +++ b/alib2std/src/extensions/map.hpp @@ -86,13 +86,28 @@ public: */ map & operator = ( const map & other ) = default; #endif + /** + * \brief + * The iterator type is inheried. + */ using iterator = typename std::map<T, R, Cmp, Alloc>::iterator; - using key_type = typename std::map<T, R, Cmp, Alloc>::key_type; - // Follow interface from C++17 - // TODO: Remove this member function after move to C++17 + /** + * \brief + * Temporary implementation of insert_or_assign from c++17 standard. + * TODO: Remove this member function after move to C++17 + * + * Follows interface from C++17 version of insert_or_assign + * + * \tparam M type of the value to insert + * + * \param k the key + * \param obj the value + * + * \return pair of iterator to the inserted or assigned key-value pair and true if the value was inserted or false if the value was asigned + */ template < typename M > - std::pair < iterator, bool > insert_or_assign ( const key_type & k, M && obj ) { + std::pair < iterator, bool > insert_or_assign ( const T & k, M && obj ) { iterator pos = this->find ( k ); if ( pos == this->end ( ) ) { pos = this->insert ( k, std::forward < M > ( obj ) ).first; @@ -103,20 +118,60 @@ public: } } + /** + * \brief + * Inherit all insert methods of the standard map. + */ using std::map< T, R, Cmp, Alloc >::insert; + /** + * \brief + * Insert variant with explicit key and value parameters. + * + * \param key the key + * \param value the value + * + * \return pair of iterator to inserted key-value pair and true if the value was inserted or false if the key already exited + */ std::pair < iterator, bool > insert ( const T & key, const R & value ) { return insert ( std::make_pair ( key, value ) ); } + /** + * \brief + * Insert variant with explicit key and value parameters. + * + * \param key the key + * \param value the value + * + * \return pair of iterator to inserted key-value pair and true if the value was inserted or false if the key already exited + */ std::pair < iterator, bool > insert ( const T & key, R && value ) { return insert ( std::make_pair ( key, std::move ( value ) ) ); } + /** + * \brief + * Insert variant with explicit key and value parameters. + * + * \param key the key + * \param value the value + * + * \return pair of iterator to inserted key-value pair and true if the value was inserted or false if the key already exited + */ std::pair < iterator, bool > insert ( T && key, const R & value ) { return insert ( std::make_pair ( std::move ( key ), value ) ); } + /** + * \brief + * Insert variant with explicit key and value parameters. + * + * \param key the key + * \param value the value + * + * \return pair of iterator to inserted key-value pair and true if the value was inserted or false if the key already exited + */ std::pair < iterator, bool > insert ( T && key, R && value ) { return insert ( std::make_pair ( std::move ( key ), std::move ( value ) ) ); } -- GitLab