[cfe-dev] [clang++][c++11] complier problems about "ranged-based for"

ZhangXiongpang zhangxiongpang at gmail.com
Fri Mar 8 14:37:58 PST 2013


James Dennett wrote
> On Fri, Mar 8, 2013 at 2:32 AM, ZhangXiongpang <

> zhangxiongpang@

> > wrote:
>> James Dennett wrote
>>>> In case (1), where "begin" and "end" are looked up as class members,
>>>> C++ doesn't allow the syntax object.TypeName,
>>
>> I know C++ doesn't allow the syntax "object.TypeName",
>> but the "object"(__begin) is a also a function object,
>> it is callable. so why not treat the object as a function?
> 
> I'm sorry, I don't understand your question.  Are you talking about
> the case of your test (3), which compiles successfully (as it should),
> or something else?

I mean in example 1 "begin" and "end" are also callable, just like the
"begin" and "end" in example 3. The difference between example 1 and example
3 is:
(1) in example 3, there is a member who named "begin" in class X, so it will
look up "x.begin()" and "x.end()", standard says "begin-expr and end-expr
are __range.begin() and __range.end(), respectively".
(2) in example 1, no member named "begin" or "end" in class X, so it will
look up "begin(x)" from the associated namespace of x, standard syas
"begin-expr and end-expr are begin(__range) and end(__range), respectively".






--
View this message in context: http://clang-developers.42468.n3.nabble.com/clang-c-11-complier-problems-about-ranged-based-for-tp4030863p4030894.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list