Community
Participate
Working Groups
The implementation of structured bindings accepts a superset of correct applications according to the C++ standard. This behavior is a deliberate design decision as we can provide better analysis and quickfixes through Codan in the problematic cases. Checkers could be implemented for: * Too many member variables in a decomposed type. The semantics currently need to have at least as many non-static members available to initialize each name. * Accessibility of the members need to be public. Example test case by Nathan Ridge: // Class with private fields class Point { private: int x; int y; void foo() { // OK, a member function can destructure a Point. auto [x, y] = *this; } friend void bar(Point p) { // OK, a friend function can destructure a Point. auto [x, y] = p; } }; void baz(Point p) { // Error, a non-member non-friend function cannot // destructure a Point. auto [x, y] = p; } * All members need to be declared in the same class or base class * The value member of tuple_size needs to be static