Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[s4u] Use const& references in Host::mounted_storages()
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 15 Jan 2016 15:05:52 +0000 (16:05 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 15 Jan 2016 15:06:05 +0000 (16:06 +0100)
examples/s4u/io/s4u_io_test.cpp
include/simgrid/s4u/host.hpp
src/s4u/s4u_host.cpp

index bc0eb0e..c2e9757 100644 (file)
@@ -16,7 +16,7 @@ public:
        myHost(const char*procname, simgrid::s4u::Host *host,int argc, char **argv)
 : simgrid::s4u::Actor(procname,host,argc,argv){}
 
-       void show_info(boost::unordered_map <std::string, simgrid::s4u::Storage*> &mounts) {
+       void show_info(boost::unordered_map <std::string, simgrid::s4u::Storage*> const&mounts) {
                XBT_INFO("Storage info on %s:",
                        simgrid::s4u::Host::current()->name().c_str());
 
@@ -35,7 +35,7 @@ public:
        }
 
        int main(int argc, char **argv) {
-               boost::unordered_map <std::string, simgrid::s4u::Storage *>& mounts =
+               boost::unordered_map <std::string, simgrid::s4u::Storage *> const& mounts =
                        simgrid::s4u::Host::current()->mounted_storages();
 
                show_info(mounts);
index 10b6bc9..be70679 100644 (file)
@@ -81,10 +81,8 @@ public:
        /** Get an associative list [mount point]->[Storage] off all local mount points.
         *
         *      This is defined in the platform file, and cannot be modified programatically (yet).
-        *
-        *      Do not change the returned value in any way.
         */
-       boost::unordered_map<std::string, Storage*> &mounted_storages();
+       boost::unordered_map<std::string, Storage*> const &mounted_storages();
 
 private:
        simgrid::xbt::string name_ = "noname";
index 615ac8b..48b5176 100644 (file)
@@ -76,7 +76,7 @@ int Host::pstates_count() const {
        return this->pimpl_cpu->getNbPStates();
 }
 
-boost::unordered_map<std::string, Storage*> &Host::mounted_storages() {
+boost::unordered_map<std::string, Storage*> const& Host::mounted_storages() {
        if (mounts == NULL) {
                mounts = new boost::unordered_map<std::string, Storage*> ();