mirror of
https://github.com/google/styleguide.git
synced 2024-03-22 13:11:43 +08:00
Allow explicit variadic constructors
This commit is contained in:
parent
155994a4bd
commit
aff6ba7a8d
8
cpplint/cpplint.py
vendored
8
cpplint/cpplint.py
vendored
|
@ -2694,6 +2694,7 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum,
|
|||
constructor_args[i] = constructor_arg
|
||||
i += 1
|
||||
|
||||
variadic_args = [arg for arg in constructor_args if '&&...' in arg]
|
||||
defaulted_args = [arg for arg in constructor_args if '=' in arg]
|
||||
noarg_constructor = (not constructor_args or # empty arg list
|
||||
# 'void' arg specifier
|
||||
|
@ -2704,7 +2705,10 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum,
|
|||
# all but at most one arg defaulted
|
||||
(len(constructor_args) >= 1 and
|
||||
not noarg_constructor and
|
||||
len(defaulted_args) >= len(constructor_args) - 1))
|
||||
len(defaulted_args) >= len(constructor_args) - 1) or
|
||||
# variadic arguments with zero or one argument
|
||||
(len(constructor_args) <= 2 and
|
||||
len(variadic_args) >= 1))
|
||||
initializer_list_constructor = bool(
|
||||
onearg_constructor and
|
||||
Search(r'\bstd\s*::\s*initializer_list\b', constructor_args[0]))
|
||||
|
@ -2717,7 +2721,7 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum,
|
|||
onearg_constructor and
|
||||
not initializer_list_constructor and
|
||||
not copy_constructor):
|
||||
if defaulted_args:
|
||||
if defaulted_args or variadic_args:
|
||||
error(filename, linenum, 'runtime/explicit', 5,
|
||||
'Constructors callable with one argument '
|
||||
'should be marked explicit.')
|
||||
|
|
Loading…
Reference in New Issue
Block a user