Multiple return value as requirements for safety and performance
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Tue Dec 20 06:47:28 PST 2016
On 12/20/2016 5:47 AM, Ilya Yaroshenko wrote:
> One good thing for safety and CTFE is allow multiple return value. In
> combination with `auto ref` it is _very_ powerful:
>
> ----
> auto ref front()
> {
> // Returns 2 values, each value is returned by reference if possible
> return (a.front, b.front);
> }
> ----
http://dlang.org/phobos/std_typecons.html#.tuple
auto ref front() {
return tuple(a.front, b.front);
}
More information about the Digitalmars-d
mailing list