[llvm-dev] When to use auto instead of iterator/const_iterator?

Zachary Turner via llvm-dev llvm-dev at lists.llvm.org
Tue May 2 14:52:19 PDT 2017


On Tue, May 2, 2017 at 9:24 AM Matthias Braun via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

>
> This should be written as:
>
> for (const SDep &Succ : SU->Succs) {
>   if (Succ.isCtrl())
>     ++NUmberDeps;
> }
>

You may even wish to write this as:

NumberDeps = llvm::count_if(SU->Succs, [](const SDep &S) { return
S.isCtrl(); });
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170502/2e344b08/attachment.html>


More information about the llvm-dev mailing list