Commit 08608724 authored by Vaclav Brozek's avatar Vaclav Brozek Committed by Commit Bot

Use std::make_reverse_iterator in password_manager

This CL adds the first use of std::make_reverse_iterator, inside the
password_manager component at a place where it shortens an awkwardly
long for-loop header.

It also adds std::make_reverse_iterator to the allowed C++14 features.

Bug: 845426
Change-Id: Ief6983c167b3c85a7d52a25555e8157d4d0f0a1c
Reviewed-on: https://chromium-review.googlesource.com/1078758Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Commit-Queue: Vaclav Brozek <vabr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562987}
parent 9c029de7
...@@ -326,9 +326,7 @@ const FormFieldData* FindUsernameFieldBaseHeuristics( ...@@ -326,9 +326,7 @@ const FormFieldData* FindUsernameFieldBaseHeuristics(
const FormFieldData* focusable_username = nullptr; const FormFieldData* focusable_username = nullptr;
const FormFieldData* username = nullptr; const FormFieldData* username = nullptr;
// Do reverse search to find the closest candidates preceding the password. // Do reverse search to find the closest candidates preceding the password.
for (auto it = std::reverse_iterator< for (auto it = std::make_reverse_iterator(first_relevant_password_it);
std::vector<const FormFieldData*>::const_iterator>(
first_relevant_password_it);
it != fields.rend(); ++it) { it != fields.rend(); ++it) {
if ((*it)->form_control_type == "password") if ((*it)->form_control_type == "password")
continue; continue;
......
...@@ -704,6 +704,14 @@ template &lt;typename T&gt;<br/>void Function(T&amp;&amp; t) { ... }</code></td> ...@@ -704,6 +704,14 @@ template &lt;typename T&gt;<br/>void Function(T&amp;&amp; t) { ... }</code></td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>Reverse Iterator Adaptor</td>
<td><code>std::make_reverse_iterator()</code></td>
<td>For a given iterator, deduces the type of a corresponding reverse iterator and constructs it.</td>
<td><a href="http://en.cppreference.com/w/cpp/iterator/make_reverse_iterator">std::make_reverse_iterator</a></td>
<td>Useful to reduce boilerplate when constructing reverse iterators. The alternative is using <code>std::reverse_iterator<T>(i)</code> where <code>T</code> is the, usually long, type of the iterator <code>i</code>. <a href="https://groups.google.com/a/chromium.org/forum/#!topic/cxx/qOE1XA0b6Dk">Discussion thread</a></td>
</tr>
</tbody> </tbody>
</table> </table>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment