On 2013-07-03, 02:22, Brad Anderson wrote:

C++11's std::tuple includes a function std::tie that takes references to the arguments and returns a tuple that maintains the references to the arguments.

Along with the usual cases where you'd want reference semantics it also enables this interesting construct for unpacking tuples.

int a, b;
tie(a, b) = make_tuple(1, 2);

assert(a == 1 && b == 2);

Is there any way to do something similar with std.typecons.Tuple?

Not that I know of. But, Philippe Sigaud's dranges[1] library includes
a RefTuple[2], which should do what you want.

[1]: https://github.com/dawgfoto/dranges/
[2]: https://github.com/dawgfoto/dranges/blob/master/reftuple.d

--
Simen

Reply via email to