What is the auto Bracketed List Syntax?

可紊 提交于 2019-12-13 12:14:49

问题


W.F. gave a now-deleted answer to my question here which used the line:

auto [x, y] = div_t{ 1, 0 };

From the code in the answer it looks like that's like a tie for the div_t struct. I was hoping that someone could explain what was going on here. The complete function code was as follows:

constexpr bool first_quot() {
    auto [x, y] = std::div_t{1, 0};
    (void)y;
    return x;
}

回答1:


In the most most recent draft of the C++17 specification it's called "Decomposition declarations" and is defined in section 8.5 [dcl.decomp].



来源:https://stackoverflow.com/questions/41569419/what-is-the-auto-bracketed-list-syntax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!