mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-09 17:52:08 -10:00
* use std::move() for local variables that are copied but not reused Addresses ~140 Coverity "Variable copied when it could be moved" defects across 74 files. Every std::move() targets a local variable whose value is consumed by push_back, emplace, assignment, lambda capture, or a function call and is never read again afterward. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * clang: use std::make_shared * clang: use std::make_unique * address feedback --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "ActionDefinition.h"
|
|
|
|
#include "expression/Value.h"
|
|
|
|
namespace actions {
|
|
|
|
template <typename TAction>
|
|
class BuiltinActionDefinition : public ActionDefinition {
|
|
using ActionValueType = typename TAction::ValueType;
|
|
|
|
public:
|
|
BuiltinActionDefinition(SCP_string name)
|
|
: ActionDefinition(std::move(name), {{"parameter", expression::ValueTypeTraits<ActionValueType>::type}})
|
|
{
|
|
}
|
|
~BuiltinActionDefinition() override = default;
|
|
|
|
flagset<ProgramContextFlags> getRequiredContext() const override
|
|
{
|
|
return flagset<ProgramContextFlags>(TAction::getRequiredExecutionContextFlags());
|
|
}
|
|
|
|
std::unique_ptr<Action> createAction(
|
|
const SCP_unordered_map<SCP_string, expression::ActionExpression>& parameterExpressions) const override
|
|
{
|
|
const auto paramIter = parameterExpressions.find("parameter");
|
|
|
|
// This should have been caught earlier
|
|
Assertion(paramIter != parameterExpressions.cend(), "Could not find built-in parameter!");
|
|
|
|
return std::make_unique<TAction>(paramIter->second.template asTyped<ActionValueType>());
|
|
}
|
|
};
|
|
|
|
} // namespace actions
|