[LLVMdev] Using C++'11 language features in LLVM itself

dag at cray.com dag at cray.com
Thu Jan 10 10:09:48 PST 2013


David Tweed <David.Tweed at arm.com> writes:

> for(std::vector<tree<bin_expr<float,true,true,false> > >::iterator it = worklist.begin(); it != worklist.end(); ++it)
>
> In cases like this auto increases readability by decreasing the amount
> of "pattern discarding" I have to do before spotting the things I'm
> going to pay attention to. If the actual type is something that the
> reader is going to think about, then IMO auto shouldn't be used as a
> coding style issue.

+1

>> rvalue-refs
>
> | It is not very helpful when compiler can do return value optimization.
>
> I thought the motivation for adding rvalue-refs in C++11 was that in
> practice compilers can almost never do enough analysis to do RVO on
> real-world code?

Not only that, but it solves the forwarding problem and helps the
compiler elide many more copies.  It's a real win.

For those not as familiar with C++11, I highly recommend perusing the
resources on cpp-next.com, particularly Dave Abrahams' articles on
rvalue references and move semantics.

The best series of articles I've read on the subject starts here:

http://cpp-next.com/archive/2009/08/want-speed-pass-by-value

Read all the articles in the series.  I came away with a completely new
understanding of how to organize and present data.

                        -David



More information about the llvm-dev mailing list