On Saturday, 7 July 2018 at 15:25:51 UTC, vino.B wrote:
Hi All,
If we replace the statement as args[$ -1] the program works
are expected, if we apply the same logic in different approach
it does not work, in the below code if we command the first
block "if (fnID == "ListFilesNames") {} " t
On Saturday, 7 July 2018 at 12:13:21 UTC, Alex wrote:
On Saturday, 7 July 2018 at 11:22:38 UTC, Timoses wrote:
Aw, got it. So args is actually a tuple type where accessing
beyond the defined tuple (T) is invalid?
auto a = [1, 2, 4];
// works
pragma(msg, typeof(a[3]));
On Saturday, 7 July 2018 at 11:22:38 UTC, Timoses wrote:
Aw, got it. So args is actually a tuple type where accessing
beyond the defined tuple (T) is invalid?
auto a = [1, 2, 4];
// works
pragma(msg, typeof(a[3]));
auto t = tuple(3, 4, 5.3);
// ERROR:
// p
On Saturday, 7 July 2018 at 08:35:27 UTC, Alex wrote:
On Saturday, 7 July 2018 at 08:24:21 UTC, Timoses wrote:
Interesting.. Looks like the compiler does some boundschecking
during compile time. You could circumvent this:
void process(T ...)(string ID, T args) {
if (ID == "I1") {
On Saturday, 7 July 2018 at 08:24:21 UTC, Timoses wrote:
Interesting.. Looks like the compiler does some boundschecking
during compile time. You could circumvent this:
void process(T ...)(string ID, T args) {
if (ID == "I1") { writeln(args.length, "\t", args[0]); }
static i
teln(args.length, "\t", args[1]);}
}
void main() {
string S1 = "Test1", S2 = "Test2", ID1 = "I1", ID2 = "I2";
int Size = 1;
process(ID1, S1);
process(ID2, S2, Size);
}
Error:
Test.d(5): Error: array index [1] is outside array bounds [0 ..
1]
Test.d(11): Er
teln(args.length, "\t", args[1]);}
}
void main() {
string S1 = "Test1", S2 = "Test2", ID1 = "I1", ID2 = "I2";
int Size = 1;
process(ID1, S1);
process(ID2, S2, Size);
}
Error:
Test.d(5): Error: array index [1] is outside array bounds [0 ..
1]
Test.d(11): Er
teln(args.length, "\t", args[1]);}
}
void main() {
string S1 = "Test1", S2 = "Test2", ID1 = "I1", ID2 = "I2";
int Size = 1;
process(ID1, S1);
process(ID2, S2, Size);
}
Error:
Test.d(5): Error: array index [1] is outside array bounds [0 ..
1]
Test.d(11): Er
ng S1 = "Test1", S2 = "Test2", ID1 = "I1", ID2 = "I2";
int Size = 1;
process(ID1, S1);
process(ID2, S2, Size);
}
Error:
Test.d(5): Error: array index [1] is outside array bounds [0 .. 1]
Test.d(11): Error: template instance `Test.process!string` error
instantiating
From,
Vino.B