Skip to content

Commit

Permalink
Delete copy constructor in ModEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCWills authored and glebm committed Jan 13, 2025
1 parent ccbf0fc commit 8f232cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 4 additions & 3 deletions Source/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ std::vector<OptionEntryBase *> ModOptions::GetEntries()
return optionEntries;
}

std::vector<ModOptions::ModEntry> &ModOptions::GetModEntries()
std::forward_list<ModOptions::ModEntry> &ModOptions::GetModEntries()
{
if (modEntries)
return *modEntries;
Expand All @@ -1738,10 +1738,11 @@ std::vector<ModOptions::ModEntry> &ModOptions::GetModEntries()
modNames.emplace_back(modName);
}

std::vector<ModOptions::ModEntry> &newModEntries = modEntries.emplace();
std::forward_list<ModOptions::ModEntry> &newModEntries = modEntries.emplace();
for (auto &modName : modNames) {
newModEntries.emplace_back(modName);
newModEntries.emplace_front(modName);
}
newModEntries.reverse();
return newModEntries;
}

Expand Down
8 changes: 6 additions & 2 deletions Source/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -819,13 +819,17 @@ struct ModOptions : OptionCategoryBase {

private:
struct ModEntry {
// OptionEntryBase::key references ModEntry::name.
// The implicit copy constructor would copy that reference instead of referencing the copy.
ModEntry(const ModEntry &) = delete;

ModEntry(std::string_view name);
std::string name;
OptionEntryBoolean enabled;
};

std::vector<ModEntry> &GetModEntries();
std::optional<std::vector<ModEntry>> modEntries;
std::forward_list<ModEntry> &GetModEntries();
std::optional<std::forward_list<ModEntry>> modEntries;
};

struct Options {
Expand Down

0 comments on commit 8f232cf

Please sign in to comment.