Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / xbt / PropertyHolder.cpp
index 92f2ff8..e77cd01 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2015-2022. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -6,6 +6,7 @@
 #include <xbt/PropertyHolder.hpp>
 
 #include <map>
+#include <memory>
 
 namespace simgrid {
 namespace xbt {
@@ -23,7 +24,7 @@ const char* PropertyHolder::get_property(const std::string& key) const
 void PropertyHolder::set_property(const std::string& key, const std::string& value)
 {
   if (not properties_)
-    properties_.reset(new std::unordered_map<std::string, std::string>);
+    properties_ = std::make_unique<std::unordered_map<std::string, std::string>>();
   (*properties_)[key] = value;
 }
 
@@ -31,7 +32,7 @@ void PropertyHolder::set_property(const std::string& key, const std::string& val
 const std::unordered_map<std::string, std::string>* PropertyHolder::get_properties()
 {
   if (not properties_)
-    properties_.reset(new std::unordered_map<std::string, std::string>);
+    properties_ = std::make_unique<std::unordered_map<std::string, std::string>>();
   return properties_.get();
 }
 
@@ -39,8 +40,8 @@ const std::unordered_map<std::string, std::string>* PropertyHolder::get_properti
 template <class Assoc> void PropertyHolder::set_properties(const Assoc& properties)
 {
   if (not properties_)
-    properties_.reset(new std::unordered_map<std::string, std::string>);
-  std::unordered_map<std::string, std::string> props(properties.cbegin(), properties.cend());
+    properties_ = std::make_unique<std::unordered_map<std::string, std::string>>();
+  std::unordered_map<std::string, std::string> props(std::cbegin(properties), std::cend(properties));
 #if __cplusplus >= 201703L
   props.merge(properties_);
 #else
@@ -49,7 +50,7 @@ template <class Assoc> void PropertyHolder::set_properties(const Assoc& properti
   properties_->swap(props);
 }
 
-template void PropertyHolder::set_properties(const std::map<std::string, std::string>& properties);
+template void PropertyHolder::set_properties(const std::map<std::string, std::string, std::less<>>& properties);
 template void PropertyHolder::set_properties(const std::unordered_map<std::string, std::string>& properties);
 
 } // namespace xbt