Skip to content

Commit ed89177

Browse files
committed
review: simplify overloaded notation
1 parent 67ff27c commit ed89177

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,25 +149,26 @@ void DescriptorTableClause::dump(raw_ostream &OS) const {
149149
OS << ")";
150150
}
151151

152-
// Helper struct so that we can use the overloaded notation of std::visit
153-
template <class... Ts> struct OverloadMethods : Ts... {
154-
using Ts::operator()...;
152+
// Helper callable so that we can use the overloaded notation of std::visit
153+
namespace {
154+
struct ElementDumper {
155+
raw_ostream &OS;
156+
template <typename T> void operator()(const T &Element) const {
157+
Element.dump(OS);
158+
}
155159
};
156-
157-
template <class... Ts> OverloadMethods(Ts...) -> OverloadMethods<Ts...>;
160+
} // namespace
158161

159162
void dumpRootElements(raw_ostream &OS, ArrayRef<RootElement> Elements) {
163+
ElementDumper Dumper{OS};
160164
OS << "RootElements{";
161165
bool First = true;
162166
for (const RootElement &Element : Elements) {
163167
if (!First)
164168
OS << ",";
165169
OS << " ";
166170
First = false;
167-
std::visit(OverloadMethods{
168-
[&OS](DescriptorTable Table) { Table.dump(OS); },
169-
[&OS](DescriptorTableClause Clause) { Clause.dump(OS); }},
170-
Element);
171+
std::visit(Dumper, Element);
171172
}
172173
OS << "}";
173174
}

0 commit comments

Comments
 (0)