diff --git a/cpplint.py b/cpplint.py index dadd142..2e80a3f 100755 --- a/cpplint.py +++ b/cpplint.py @@ -5941,7 +5941,7 @@ def ExpectingFunctionArgs(clean_lines, linenum): # Match max(..., ...), max(..., ...), but not foo->max, foo.max or # 'type::max()'. _re_pattern_headers_maybe_templates.append( - (re.compile(r'[^>.]\b' + _template + r'(<.*?>)?\([^\)]'), + (re.compile(r'((\bstd::)|[^>.:])\b' + _template + r'(<.*?>)?\([^\)]'), _template, _header)) # Match set, but not foo->set, foo.set diff --git a/cpplint_unittest.py b/cpplint_unittest.py index 9a47259..b42c08f 100755 --- a/cpplint_unittest.py +++ b/cpplint_unittest.py @@ -1052,7 +1052,12 @@ def testIncludeWhatYouUse(self): '[build/include_what_you_use] [4]') self.TestIncludeWhatYouUse( """#include "base/foobar.h" - bool foobar = min_element(a.begin(), a.end()); + boost::range::transform(input, std::back_inserter(output), square); + """, + '') # Avoid false positives on transform in other namespaces. + self.TestIncludeWhatYouUse( + """#include "base/foobar.h" + bool foobar = std::min_element(a.begin(), a.end()); """, 'Add #include for min_element ' '[build/include_what_you_use] [4]')