Namespaces
Variants
Views
Actions

Talk:cpp/language/range-for

From cppreference.com

[edit] Use technical detail of standard

The standard says that really "auto __begin = std::Range<_RangeT>::begin(__range)", but I abbreviated this to just "__begin = __range.begin()". Do you think this loses accuracy. It improves readability. -- Jaredgrubb 08:33, 2 July 2011 (PDT)

@Jaredgrubb: Are you reading an up-to-date version of the draft? I believe n3242 is the most up-to-date, and I see no mention in it of the <iterator_concept> header, nor std::Range. --Benjamin Lindley 12:27, 2 July 2011 (PDT)

Ah, I was using n2243 [1], which I found a link to on the Clang pages. Looks like GCC is based on n2930 [2]. I cant find n3242. You have any advice on how to find the one in the "final" proposal - Jaredgrubb 17:49, 2 July 2011 (PDT)

Ok here's n3242 [3]. I'll review and fix the text.

[edit] Type inference

Does the type inference default to reference or value? I'm not entirely sure of this and it would probably be a good thing to mention on the page. --- Undeterminant 14:00, 30 April 2012 (PDT)

If you're referring to the keyword auto, it is explained on auto's page (to put it simple, auto makes the loop variable a copy of the container's element, auto& makes it a reference to the container's element, const auto& makes it a const reference). --Cubbi 19:46, 30 April 2012 (PDT)