X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5a4bab52900d62dfd3dec063ece907974899db09..3f4f5e63dadc0023c0a02a08af8e9e9801b38e8e:/src/xbt/PropertyHolder.cpp diff --git a/src/xbt/PropertyHolder.cpp b/src/xbt/PropertyHolder.cpp index 8b62106b8c..945d4c9946 100644 --- a/src/xbt/PropertyHolder.cpp +++ b/src/xbt/PropertyHolder.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2015-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2015-2023. 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,9 +6,9 @@ #include #include +#include -namespace simgrid { -namespace xbt { +namespace simgrid::xbt { /** @brief Return the property associated to the provided key (or nullptr if not existing) */ const char* PropertyHolder::get_property(const std::string& key) const @@ -23,7 +23,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); + properties_ = std::make_unique>(); (*properties_)[key] = value; } @@ -31,7 +31,7 @@ void PropertyHolder::set_property(const std::string& key, const std::string& val const std::unordered_map* PropertyHolder::get_properties() { if (not properties_) - properties_.reset(new std::unordered_map); + properties_ = std::make_unique>(); return properties_.get(); } @@ -39,18 +39,17 @@ const std::unordered_map* PropertyHolder::get_properti template void PropertyHolder::set_properties(const Assoc& properties) { if (not properties_) - properties_.reset(new std::unordered_map); - std::unordered_map props(properties.cbegin(), properties.cend()); + properties_ = std::make_unique>(); + std::unordered_map props(std::cbegin(properties), std::cend(properties)); #if __cplusplus >= 201703L - props.merge(properties_); + props.merge(*properties_); #else props.insert(properties_->cbegin(), properties_->cend()); #endif properties_->swap(props); } -template void PropertyHolder::set_properties(const std::map& properties); +template void PropertyHolder::set_properties(const std::map>& properties); template void PropertyHolder::set_properties(const std::unordered_map& properties); -} // namespace xbt -} // namespace simgrid +} // namespace simgrid::xbt