Skip to content
19 changes: 10 additions & 9 deletions src/api/cpp/nixl_descriptors.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,18 @@ class nixlDescList {
*/
inline bool
isEmpty() const {
return (descs.size() == 0);
return descs.empty();
}

/**
* @brief Operator [] overloading, get/set descriptor at [index].
* Can throw std::out_of_range exception.
*/
const T &
operator[](unsigned int index) const;
virtual T &
operator[](unsigned int index);
inline const T &
Comment thread
rakhmets marked this conversation as resolved.
Resolved
operator[](unsigned int index) const {
return descs[index];
}

inline T &
Comment thread
iyastreb marked this conversation as resolved.
Resolved
operator[](unsigned int index) {
return descs[index];
}
Comment thread
iyastreb marked this conversation as resolved.
Resolved

/**
* @brief Vector like iterators for const and non-const elements
Expand Down
2 changes: 1 addition & 1 deletion src/infra/mem_section.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class nixlSecDescList : public nixlDescList<nixlSectionDesc> {
verifySorted() const;

nixlSectionDesc &
operator[](unsigned int index) override;
operator[](unsigned int index);

int
getIndex(const nixlBasicDesc &query) const override;
Expand Down
16 changes: 0 additions & 16 deletions src/infra/nixl_descriptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,6 @@ nixlDescList<T>::nixlDescList(nixlSerDes* deserializer) {
}
}

// Getter
template <class T>
inline const T& nixlDescList<T>::operator[](unsigned int index) const {
// To be added only in debug mode
// if (index >= descs.size())
// throw std::out_of_range("Index is out of range");
return descs[index];
}

// Setter
template <class T>
inline T& nixlDescList<T>::operator[](unsigned int index) {
assert(index < descs.size());
Comment thread
brminich marked this conversation as resolved.
Resolved
return descs[index];
}

template <class T>
void nixlDescList<T>::addDesc (const T &desc) {
descs.push_back(desc);
Expand Down