Const Tuples
bearophile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Apr 25 06:29:48 PDT 2014
> import std.typecons: Tuple, tuple;
> import std.algorithm: reduce;
>
> struct Foo { int x; }
>
> auto foo(in Tuple!(Foo[]) arg, int) {
> return tuple(arg[0]);
> }
>
> void main() {
> int[] data;
> Foo[] empty;
> auto seed = tuple(empty);
> reduce!foo(seed, data);
> }
I have found a solution:
import std.typecons: Tuple, tuple;
import std.algorithm: reduce;
auto foo(in Tuple!(const(int)[]) arg, int) {
return tuple(arg[0]);
}
void main() {
int[] empty;
Tuple!(const(int)[]) seed;
reduce!foo(seed, [1]);
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list