diff --git a/mlir/include/mlir/IR/DialectImplementation.h b/mlir/include/mlir/IR/DialectImplementation.h --- a/mlir/include/mlir/IR/DialectImplementation.h +++ b/mlir/include/mlir/IR/DialectImplementation.h @@ -140,12 +140,18 @@ } }; +namespace detail { +template +using has_push_back_t = decltype( + std::declval().push_back(std::declval())); +} // namespace detail + /// Parse any container that supports back insertion as a list. template -struct FieldParser< - ContainerT, std::enable_if_t::value, - ContainerT>> { +struct FieldParser::value, + ContainerT>> { using ElementT = typename ContainerT::value_type; static FailureOr parse(AsmParser &parser) { ContainerT elements; @@ -153,7 +159,7 @@ auto element = FieldParser::parse(parser); if (failed(element)) return failure(); - elements.push_back(*element); + elements.push_back(std::move(*element)); return success(); }; if (parser.parseCommaSeparatedList(elementParser))