File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -189,13 +189,21 @@ void Hdf5Recorder::compileHistories()
189189 } else if (variableInfo.hdf5Datatype_ == PredType::NATIVE_INT) {
190190 vector<int > dataBuffer (variableInfo.variableLocation_ .getNumElements ());
191191 for (size_t i = 0 ; i < variableInfo.variableLocation_ .getNumElements (); ++i) {
192- if constexpr (std::is_same_v<
192+ // For type int, a distinction needs to be made between vertexType and regular integers
193+ // Since vertexType is an enum class, it needs to first be converted to an integer before storing
194+
195+ // 'decltype' determines the type at compile time
196+ // 'decay_t' removes any references/const from the type
197+ // This simplifies comparisons through 'is_same_v' to ensure type matches vertexType
198+ if (std::is_same_v<
193199 vertexType,
194200 std::decay_t <decltype (get<vertexType>(
195201 variableInfo.variableLocation_ .getElement (i)))>>) {
202+ // If type matches vertexType, convert to int before storing
196203 dataBuffer[i] = static_cast <int >(
197204 get<vertexType>(variableInfo.variableLocation_ .getElement (i)));
198205 } else {
206+ // Otherwise, store as a regular integer
199207 dataBuffer[i] = get<int >(variableInfo.variableLocation_ .getElement (i));
200208 }
201209 }
Original file line number Diff line number Diff line change @@ -138,11 +138,19 @@ class Hdf5Recorder : public Recorder {
138138 } else if (hdf5Datatype_ == PredType::NATIVE_INT) {
139139 vector<int > dataBuffer (variableLocation_.getNumElements ());
140140 for (int i = 0 ; i < variableLocation_.getNumElements (); ++i) {
141- if constexpr (std::is_same_v<vertexType, std::decay_t <decltype (get<vertexType>(
141+ // For type int, a distinction needs to be made between vertexType and regular integers
142+ // Since vertexType is an enum class, it needs to first be converted to an integer before storing
143+
144+ // 'decltype' determines the type at compile time
145+ // 'decay_t' removes any references/const from the type
146+ // This simplifies comparisons through 'is_same_v' to ensure type matches vertexType
147+ if (std::is_same_v<vertexType, std::decay_t <decltype (get<vertexType>(
142148 variableLocation_.getElement (i)))>>) {
149+ // If type matches vertexType, convert to int before storing
143150 dataBuffer[i]
144151 = static_cast <int >(get<vertexType>(variableLocation_.getElement (i)));
145152 } else {
153+ // Otherwise, store as a regular integer
146154 dataBuffer[i] = get<int >(variableLocation_.getElement (i));
147155 }
148156 }
You can’t perform that action at this time.
0 commit comments