English 中文(简体)
为什么没有发现白白白白白白白白白白白白白白白灯的标志性标志。
原标题:Why does name lookup in the parameter-declaration-clause of a lambda expression not find init-captures?

考虑这一例子

int main() {
    const char* x;
    [x = 1] (decltype(-x) y) {};
}

https://godbolt.org/z/5cnhzTo34”rel=“nofollow noreferer”> 我在Gobolt

不过,我可以指出,标准为什么要求这样做。 http://eel.is/c++draft/expr.prim.lambda.capture#6”rel=“nofollow noreferer”[expr.prim.lambda.capture]/6,

a init-capture inhabits the lambda scope ([basic.cop.lambda]) of the lambda-expression。 [......]

The lambda scope is defined in [basic.cop.lambda]:

www.un.org/chinese/ga/president

<>m>lambda-introducer 是方括号内的部分,因此,在[x = 1]的封闭式方括号之后,“x的名称查询应当立即开始找到init-capture,而不是x在封闭式封条范围内宣布的。

但是,据汇编者称,虽然我们仍然在分参数-声明-clause上,但名称查询x 则没有发现init-capture。 我肯定他们会回声,有点错,但这是什么?

问题回答

[expr.prim.lambda.capture]/11:

(斜体地雷)

Every id-expression within the compound-statement of a lambda-expression that is an odr-use ([basic.def.odr]) of an entity captured by copy is transformed into an access to the corresponding unnamed data member of the closure type.

[Note 7: An id-expression that is not an odr-use refers to the original entity, never to a member of the closure type. However, such an id-expression can still cause the implicit capture of the entity. — end note]

这意味着decltype(-x),x系指在lambda之前确定的当地变量x





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签