From 11484205f5f2c30a735c13aaea44bc5a7e932fd7 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Thu, 23 Mar 2023 14:29:26 +0400 Subject: [PATCH] Use constexpr to do not generate an invalid code in templates --- apps/opencs/model/world/collection.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index e177291a7c..e8847253d2 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -269,11 +269,15 @@ namespace CSMWorld copy->mState = RecordBase::State_ModifiedOnly; setRecordId(destination, copy->get()); - if (type == UniversalId::Type_Reference) + if constexpr (std::is_same_v) { - CSMWorld::CellRef* ptr = (CSMWorld::CellRef*)©->mModified; - ptr->mRefNum.mIndex = 0; + if (type == UniversalId::Type_Reference) + { + CSMWorld::CellRef* ptr = (CSMWorld::CellRef*)©->mModified; + ptr->mRefNum.mIndex = 0; + } } + const int index = getAppendIndex(destination, type); insertRecord(std::move(copy), getAppendIndex(destination, type));