Skip to content

cpplint/cpplint.py false positive error for copy constructor #485

@netmonitoring

Description

@netmonitoring

According to C++ specification:

A copy constructor of class T is a non-template constructor whose first parameter is T&‍, const T&‍, volatile T&‍, or const volatile T&‍, and either there are no other parameters, or the rest of the parameters all have default values.

The file cpplint/cpplint.py line number 2920 should be modified.

From: Match(r'(const\s+)?%s(\s*<[^>]*>)?(\s+const)?\s*(?:<\w+>\s*)?&'

To: Match(r'((?:const|volatile|const\s+volatile|volatile\s+const)\s+)?%s(\s*<[^>]*>)?(\s+const)?\s*(?:<\w+>\s*)?&'

To prevent false positive ccplint error:

error cpplint: [runtime/explicit] Single-parameter constructors should be marked explicit.

When copy constructor is defined like:
MyClass(volatile MyClass& rhs)
MyClass(const volatile MyClass& rhs);
MyClass(volatile const MyClass& rhs);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions