styleguide icon indicating copy to clipboard operation
styleguide copied to clipboard

cpplint/cpplint.py false positive error for copy constructor

Open netmonitoring opened this issue 6 years ago • 0 comments

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);

netmonitoring avatar Nov 06 '19 00:11 netmonitoring