OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 namespace std { |
| 6 |
| 7 // This is the move that should be flagged. Representes the unary std::move. |
| 8 template <typename T> |
| 9 T move(T t) { |
| 10 return t; |
| 11 } |
| 12 |
| 13 // This represents the algorithm std::move, it should not be flagged. |
| 14 template <class InputIt, class OutputIt> |
| 15 OutputIt move(InputIt first, InputIt last, OutputIt d_first) { |
| 16 return d_first; |
| 17 } |
| 18 |
| 19 } // namespace std |
| 20 |
| 21 // This represents some non-std move. It should not be flagged. |
| 22 template <typename T> |
| 23 T move(T t) { |
| 24 return t; |
| 25 } |
| 26 |
| 27 void Test() { |
| 28 int x = 3; |
| 29 |
| 30 // Should not be flagged: x is not a pointer. |
| 31 int y = std::move(x); |
| 32 |
| 33 int* p = &x; |
| 34 |
| 35 // Calling std::move on a raw pointer should be flagged. |
| 36 int* q = /*This tries to move a raw pointer!*/ std::move(p); |
| 37 |
| 38 // Calling non-std move should not be flagged. |
| 39 q = move(p); |
| 40 } |
OLD | NEW |