X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9ba3bfdef0f13d77474c16059ca813b75ade43ab..fad5cac0b9b8063848d3cb9b726bbfea5b8ebee8:/include/xbt/Extendable.hpp diff --git a/include/xbt/Extendable.hpp b/include/xbt/Extendable.hpp index 81e7150625..1da9b31238 100644 --- a/include/xbt/Extendable.hpp +++ b/include/xbt/Extendable.hpp @@ -24,7 +24,7 @@ class Extension { friend class Extendable; constexpr Extension(std::size_t id) : id_(id) {} public: - constexpr Extension() : id_(INVALID_ID) {} + explicit constexpr Extension() : id_(INVALID_ID) {} std::size_t id() const { return id_; } bool valid() { return id_ != INVALID_ID; } }; @@ -41,14 +41,13 @@ public: * with a notion of Host extended with another concept (such as mobility). * You could completely externalize these data with an associative map Host->EnergyHost. * It would work, provided that you implement this classical feature correctly (and it would induce a little performance penalty). - * Instead, you should add a new facet to the Host class, that happens to be Facetable. + * Instead, you should add a new extension to the Host class, that happens to be Extendable. * */ template class Extendable { private: static std::vector deleters_; -protected: std::vector extensions_; public: static size_t extension_create(void (*deleter)(void*)) @@ -77,7 +76,7 @@ public: * an extension of B might need to have the extension of A around when executing * its cleanup function/destructor. */ for (std::size_t i = extensions_.size(); i > 0; --i) - if (extensions_[i - 1] != nullptr) + if (extensions_[i - 1] != nullptr && deleters_[i - 1] != nullptr) deleters_[i - 1](extensions_[i - 1]); }