X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2cbb80e4efe5bef8a6d6d8a14f7a35729421e21c..172a73b13fe909117c7fbf3d69d4ce5e87efdbc6:/src/smpi/mpi/smpi_info.cpp diff --git a/src/smpi/mpi/smpi_info.cpp b/src/smpi/mpi/smpi_info.cpp index ff3c8535d8..160892edb7 100644 --- a/src/smpi/mpi/smpi_info.cpp +++ b/src/smpi/mpi/smpi_info.cpp @@ -32,15 +32,16 @@ void Info::set(char *key, char *value){ int Info::get(char *key, int valuelen, char *value, int *flag){ *flag=false; - try { - std::string tmpvalue = map_.at(key); + auto val = map_.find(key); + if (val != map_.end()) { + std::string tmpvalue = val->second; memset(value, 0, valuelen); memcpy(value, tmpvalue.c_str(), (tmpvalue.length() + 1 < static_cast(valuelen)) ? tmpvalue.length() + 1 : valuelen); *flag=true; return MPI_SUCCESS; - } catch (std::out_of_range& unfound) { + } else { return MPI_ERR_INFO_KEY; } } @@ -59,7 +60,7 @@ int Info::get_nkeys(int *nkeys){ int Info::get_nthkey(int n, char *key){ int num=0; - for (auto elm : map_) { + for (auto const& elm : map_) { if (num == n) { strncpy(key, elm.first.c_str(), elm.first.length() + 1); return MPI_SUCCESS; @@ -71,11 +72,12 @@ int Info::get_nthkey(int n, char *key){ int Info::get_valuelen(char *key, int *valuelen, int *flag){ *flag=false; - try { - *valuelen = map_.at(key).length(); + auto val = map_.find(key); + if (val != map_.end()) { + *valuelen = val->second.length(); *flag=true; return MPI_SUCCESS; - } catch (std::out_of_range& unfound) { + } else { return MPI_ERR_INFO_KEY; } }