Skip to content

Commit

Permalink
Fix IndexedOpPart struct to remove unnecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
raccog committed Nov 6, 2023
1 parent 036fd55 commit 1761362
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/isa/instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,21 @@ struct FieldLinkRequest {
QString relocation = QString();
};

template <typename... AllOpParts>
struct IndexedOpPart {
static std::unique_ptr<OpPartBase> GetOpPart(unsigned) {
assert(false);
return nullptr;
}
};
/// Struct used to dynamically index OpParts
template <typename OpPart, typename... NextOpParts>
struct IndexedOpPart<OpPart, NextOpParts...> {
struct IndexedOpPart {
static std::unique_ptr<OpPartBase> GetOpPart(unsigned partIndex) {
if (partIndex == 0)
assert(partIndex < sizeof...(NextOpParts) + 1 &&
"OpPart index out of range");
if (partIndex == 0) {
// OpPart found
return std::unique_ptr<OpPartBase>(std::make_unique<OpPart>());
return IndexedOpPart<NextOpParts...>::GetOpPart(partIndex - 1);
} else if constexpr (sizeof...(NextOpParts) > 0) {
// Check next OpPart
return IndexedOpPart<NextOpParts...>::GetOpPart(partIndex - 1);
}

Q_UNREACHABLE();
}
};

Expand Down

0 comments on commit 1761362

Please sign in to comment.