Tuple issue
DLearner
bmqazwsx123 at gmail.com
Mon Nov 16 16:07:20 UTC 2026
On Monday, 16 November 2026 at 11:20:56 UTC, Nick Treleaven wrote:
[...]
I've not tried it with -betterC[...]
Using dmd -betterC -preview=tuples (dmd 2.114.0, Windows 10):
```
extern(C) void main() {
// import std.typecons : tuple;
import std.typecons;
Tuple!(int, int) fnTuple1(int Parm) {
int retval1;
int retval2;
retval1 = 2*Parm;
retval2 = 3*Parm;
return tuple(retval1, retval2);
}
auto (Arg1, Arg2) = fnTuple1(4);
assert(Arg1 == 8);
assert(Arg2 == 12);
}
```
works.
However, following the doc link:
```
extern(C) void main() {
import std.typecons : tuple;
// import std.typecons;
Tuple!(int, int) fnTuple1(int Parm) {
int retval1;
int retval2;
retval1 = 2*Parm;
retval2 = 3*Parm;
return tuple(retval1, retval2);
}
auto (Arg1, Arg2) = fnTuple1(4);
assert(Arg1 == 8);
assert(Arg2 == 12);
}
```
fails with Error: template instance `Tuple!(int, int)` template
`Tuple` is not defined.
But:
```
extern(C) void main() {
import std.typecons : Tuple, tuple;
// import std.typecons;
Tuple!(int, int) fnTuple1(int Parm) {
int retval1;
int retval2;
retval1 = 2*Parm;
retval2 = 3*Parm;
return tuple(retval1, retval2);
}
auto (Arg1, Arg2) = fnTuple1(4);
assert(Arg1 == 8);
assert(Arg2 == 12);
}
```
succeeds.
More information about the Digitalmars-d-learn
mailing list