This is an automated email from the ASF dual-hosted git repository. astitcher pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
commit 6971aebdfda271185e6ccd447f017a466f47fdbd Author: Rakhi Kumari <[email protected]> AuthorDate: Mon Jan 10 18:08:09 2022 +0530 PROTON-2481: [cpp] Improve constructor syntax for maps - Add a copy constructor to copy from std::map - Add an initializer_list constructor --- cpp/include/proton/map.hpp | 8 ++++++++ cpp/src/map.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/cpp/include/proton/map.hpp b/cpp/include/proton/map.hpp index 5bff48f..86874c5 100644 --- a/cpp/include/proton/map.hpp +++ b/cpp/include/proton/map.hpp @@ -25,6 +25,8 @@ #include "./value.hpp" #include <cstddef> +#include <initializer_list> +#include <map> #include <memory> /// @file @@ -79,6 +81,12 @@ class PN_CPP_CLASS_EXTERN map { /// Copy a map. PN_CPP_EXTERN map& operator=(const map&); + /// Copy a std::map. + PN_CPP_EXTERN map(const std::map<K, T>&); + + /// Initializer_list constructor. + PN_CPP_EXTERN map(const std::initializer_list<std::pair<const K, T>>&); + /// Move a map. PN_CPP_EXTERN map(map&&); diff --git a/cpp/src/map.cpp b/cpp/src/map.cpp index 6ff62ee..6c9d442 100644 --- a/cpp/src/map.cpp +++ b/cpp/src/map.cpp @@ -49,6 +49,14 @@ template <class K, class T> map<K,T>::map(const map& x) { *this = x; } template <class K, class T> +map<K, T>::map(const std::map<K, T>& x) { *this = x; } + +template <class K, class T> +map<K, T>::map(const std::initializer_list<std::pair<const K, T>>& x) { + *this = std::map<K, T>(x); +} + +template <class K, class T> map<K,T>::map(pn_data_t *d) : value_(d) { // NOTE: for internal use. Don't verify that the data is valid here as that // would forcibly decode message maps immediately, we want to decode on-demand. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
