this);
Finder->addMatcher(
cxxConstructorDecl(
- unless(hasParent(IsUnionLikeClass)), isDefinition(),
+ unless(
+ hasParent(decl(anyOf(IsUnionLikeClass, functionTemplateDecl())))),
+ isDefinition(),
anyOf(
// Default constructor.
allOf(unless(hasAnyConstructorInitializer(isWritten())),
this);
// Copy-assignment operator.
Finder->addMatcher(
- cxxMethodDecl(unless(hasParent(IsUnionLikeClass)), isDefinition(),
- isCopyAssignmentOperator(),
+ cxxMethodDecl(unless(hasParent(
+ decl(anyOf(IsUnionLikeClass, functionTemplateDecl())))),
+ isDefinition(), isCopyAssignmentOperator(),
// isCopyAssignmentOperator() allows the parameter to be
// passed by value, and in this case it cannot be
// defaulted.
The check now skips unions/union-like classes since in this case a default constructor
with empty body is not equivalent to the explicitly defaulted one, variadic constructors
since they cannot be explicitly defaulted. The check also skips copy assignment operators
- with nonstandard return types, private/protected default constructors for C++17 or earlier.
- The automatic fixit has been adjusted to avoid adding superfluous semicolon.
- The check is restricted to C++11 or later.
+ with nonstandard return types, template constructors, private/protected default constructors
+ for C++17 or earlier. The automatic fixit has been adjusted to avoid adding superfluous
+ semicolon. The check is restricted to C++11 or later.
- Change the default behavior of :doc:`readability-avoid-const-params-in-decls
<clang-tidy/checks/readability/avoid-const-params-in-decls>` to not
VA(...) {}
};
+// Skip template constructors.
+struct TC {
+ template <unsigned U>
+ TC() {}
+
+ template <unsigned U>
+ TC(const TC &) {}
+
+ template <unsigned U>
+ TC& operator = (const TC &) { return *this; }
+};
+
// Initializer or arguments.
class IA {
public: