Skip to content

Commit 779fa71

Browse files
Merge pull request #2253 from peterschrammel/documentation/override2
Get legalistic about use of override without virtual
2 parents 40ecff8 + 050b344 commit 779fa71

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

CODING_STANDARD.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Formatting is enforced using clang-format. For more information about this, see
156156
- Make references `const` whenever possible
157157
- Make member functions `const` whenever possible
158158
- Do not hide base class functions
159-
- You are encouraged to use `override`
159+
- When overriding a virtual function, use `override` (without `virtual`)
160160
- Single argument constructors must be `explicit`
161161
- Avoid implicit conversions
162162
- Avoid `friend` declarations

scripts/cpplint.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6148,21 +6148,21 @@ def CheckRedundantVirtual(filename, clean_lines, linenum, error):
61486148
if end_col < 0:
61496149
return # Couldn't find end of parameter list, give up
61506150

6151-
# # Look for "override" or "final" after the parameter list
6152-
# # (possibly on the next few lines).
6153-
# for i in xrange(end_line, min(end_line + 3, clean_lines.NumLines())):
6154-
# line = clean_lines.elided[i][end_col:]
6155-
# match = Search(r'\b(override|final)\b', line)
6156-
# if match:
6157-
# error(filename, linenum, 'readability/inheritance', 4,
6158-
# ('"virtual" is redundant since function is '
6159-
# 'already declared as "%s"' % match.group(1)))
6160-
#
6161-
# # Set end_col to check whole lines after we are done with the
6162-
# # first line.
6163-
# end_col = 0
6164-
# if Search(r'[^\w]\s*$', line):
6165-
# break
6151+
# Look for "override" or "final" after the parameter list
6152+
# (possibly on the next few lines).
6153+
for i in xrange(end_line, min(end_line + 3, clean_lines.NumLines())):
6154+
line = clean_lines.elided[i][end_col:]
6155+
match = Search(r'\b(override|final)\b', line)
6156+
if match:
6157+
error(filename, linenum, 'readability/inheritance', 4,
6158+
('"virtual" is redundant since function is '
6159+
'already declared as "%s"' % match.group(1)))
6160+
6161+
# Set end_col to check whole lines after we are done with the
6162+
# first line.
6163+
end_col = 0
6164+
if Search(r'[^\w]\s*$', line):
6165+
break
61666166

61676167

61686168

0 commit comments

Comments
 (0)