What are use cases for structured bindings?

前端 未结 4 1397
滥情空心
滥情空心 2020-12-05 13:24

C++17 standard introduces a new structured bindings feature, which was initially proposed in 2015 and whose syntactic appearance was widely discussed later.

Some use

4条回答
  •  伪装坚强ぢ
    2020-12-05 14:00

    Initializing multiple variables of different types in an if statement; for instance,

    if (auto&& [a, b] = std::pair { std::string { "how" }, 4U }; a.length() < b)
       std::cout << (a += " convenient!") << '\n';
    

提交回复
热议问题