================ @@ -0,0 +1,58 @@ +.. title:: clang-tidy - modernize-use-structured-binding + +modernize-use-structured-binding +================================ + +Suggests using C++17 structured bindings to decompose pairs. + +This check finds three code patterns and recommends using structured bindings for clearer, more idiomatic C++17 code. + +1. Decompose a pair variable by assigning its members to separate variables right after its definition: + +.. code-block:: c++ + + auto p = getPair<int, int>(); + int x = p.first; + int y = p.second; + + into: + + auto [x, y] = getPair<int, int>(); + +2. Use `std::tie` to decompose a pair into two predefined variables: ---------------- vbvictor wrote:
```suggestion 2. Use ``std::tie`` to decompose a pair into two predefined variables: ``` Language constructs in double-ticks https://github.com/llvm/llvm-project/pull/158462 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
