- if(comm->attributes !=nullptr){
- (*newcomm)->attributes=xbt_dict_new();
- xbt_dict_cursor_t cursor = nullptr;
- int *key;
- int flag;
- void* value_in;
- void* value_out;
- xbt_dict_foreach(comm->attributes, cursor, key, value_in){
- smpi_comm_key_elem elem =
- static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast<const char*>(key), sizeof(int)));
- if(elem!=nullptr && elem->copy_fn!=MPI_NULL_COPY_FN){
- ret = elem->copy_fn(comm, *key, nullptr, value_in, &value_out, &flag );
- if(ret!=MPI_SUCCESS){
- smpi_comm_destroy(*newcomm);
- *newcomm=MPI_COMM_NULL;
- xbt_dict_cursor_free(&cursor);
- return ret;
- }
- if(flag)
- xbt_dict_set_ext((*newcomm)->attributes, reinterpret_cast<const char*>(key), sizeof(int),value_out, nullptr);
+ if(!attributes()->empty()){
+ int flag;
+ void* value_out;
+ for(auto it : *attributes()){
+ smpi_key_elem elem = keyvals_.at(it.first);
+ if (elem != nullptr && elem->copy_fn.comm_copy_fn != MPI_NULL_COPY_FN) {
+ ret = elem->copy_fn.comm_copy_fn(this, it.first, nullptr, it.second, &value_out, &flag);
+ if (ret != MPI_SUCCESS) {
+ Comm::destroy(*newcomm);
+ *newcomm = MPI_COMM_NULL;
+ return ret;