-/* Copyright (c) 2007-2017. The SimGrid Team.
+/* Copyright (c) 2007-2018. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
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<size_t>(valuelen)) ? tmpvalue.length() + 1 : valuelen);
*flag=true;
return MPI_SUCCESS;
- } catch (std::out_of_range& unfound) {
+ } else {
return MPI_ERR_INFO_KEY;
}
}
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;
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;
}
}