// unpack an array auto nums = [ 1, 2, 3 ]; int a, b, c; let( a, b, c ) = nums; // access the array indices and assign them to the a, b, and c variables // unpack a struct with a built-in deconstructor struct Point { immutable int x; immutable int y; void deconstruct( int* x, int* y ) { *x = this.x; *y = this.y; } } auto pt = Point( 5, 6 ); int x, y; let( x, y ) = pt; // call Point.deconstruct() with pointers to the x and y variables
Copyright © 2017-2019, Tony J. Hudgins
MIT
Unpacks forward ranges, input ranges, static arrays, dynamic arrays, tuples, and user-defined types (via deconstructor methods) into the specified variables.