@@ -181,57 +181,22 @@ class Dialect {
181
181
// / This method is used by derived classes to add their operations to the set.
182
182
// /
183
183
template <typename ... Args> void addOperations () {
184
- VariadicOperationAdder<Args...>::addToSet (*this );
184
+ (void )std::initializer_list<int >{
185
+ 0 , (addOperation (AbstractOperation::get<Args>(*this )), 0 )...};
185
186
}
186
187
187
- // It would be nice to define this as variadic functions instead of a nested
188
- // variadic type, but we can't do that: function template partial
189
- // specialization is not allowed, and we can't define an overload set because
190
- // we don't have any arguments of the types we are pushing around.
191
- template <typename First, typename ... Rest> class VariadicOperationAdder {
192
- public:
193
- static void addToSet (Dialect &dialect) {
194
- dialect.addOperation (AbstractOperation::get<First>(dialect));
195
- VariadicOperationAdder<Rest...>::addToSet (dialect);
196
- }
197
- };
198
-
199
- template <typename First> class VariadicOperationAdder <First> {
200
- public:
201
- static void addToSet (Dialect &dialect) {
202
- dialect.addOperation (AbstractOperation::get<First>(dialect));
203
- }
204
- };
205
-
206
188
void addOperation (AbstractOperation opInfo);
207
189
208
190
// / This method is used by derived classes to add their types to the set.
209
191
template <typename ... Args> void addTypes () {
210
- VariadicSymbolAdder<Args...>:: addToSet (* this ) ;
192
+ ( void )std::initializer_list< int >{ 0 , ( addSymbol ( Args::getClassID ()), 0 )...} ;
211
193
}
212
194
213
195
// / This method is used by derived classes to add their attributes to the set.
214
196
template <typename ... Args> void addAttributes () {
215
- VariadicSymbolAdder<Args...>:: addToSet (* this ) ;
197
+ ( void )std::initializer_list< int >{ 0 , ( addSymbol ( Args::getClassID ()), 0 )...} ;
216
198
}
217
199
218
- // It would be nice to define this as variadic functions instead of a nested
219
- // variadic type, but we can't do that: function template partial
220
- // specialization is not allowed, and we can't define an overload set
221
- // because we don't have any arguments of the types we are pushing around.
222
- template <typename First, typename ... Rest> struct VariadicSymbolAdder {
223
- static void addToSet (Dialect &dialect) {
224
- VariadicSymbolAdder<First>::addToSet (dialect);
225
- VariadicSymbolAdder<Rest...>::addToSet (dialect);
226
- }
227
- };
228
-
229
- template <typename First> struct VariadicSymbolAdder <First> {
230
- static void addToSet (Dialect &dialect) {
231
- dialect.addSymbol (First::getClassID ());
232
- }
233
- };
234
-
235
200
// / Enable support for unregistered operations.
236
201
void allowUnknownOperations (bool allow = true ) { unknownOpsAllowed = allow; }
237
202
@@ -242,12 +207,9 @@ class Dialect {
242
207
void addInterface (std::unique_ptr<DialectInterface> interface);
243
208
244
209
// / Register a set of dialect interfaces with this dialect instance.
245
- template <typename T, typename T2, typename ... Tys> void addInterfaces () {
246
- addInterfaces<T>();
247
- addInterfaces<T2, Tys...>();
248
- }
249
- template <typename T> void addInterfaces () {
250
- addInterface (std::make_unique<T>(this ));
210
+ template <typename ... Args> void addInterfaces () {
211
+ (void )std::initializer_list<int >{
212
+ 0 , (addInterface (std::make_unique<Args>(this )), 0 )...};
251
213
}
252
214
253
215
private:
0 commit comments