Identifier right after a template Type
Ali Çehreli
acehreli at yahoo.com
Thu Jun 22 09:19:39 UTC 2023
On 6/22/23 00:49, Puneet Goel wrote:
> Foo!q{foo}cc;
[...]
> // p.c // q{foo}c is taken as a string
In case it's not clear to all: q{foo}c is the equivalent of "foo"c,
which means a string consisting of chars (as usual).
This issue is somewhat related to something I've struggled with just
today. The following expression that sums up 10,000 values came up 0! What?
import std;
void main() {
const result = iota(10,000).map!(i => foo(i)).sum;
writeln(result); // Prints 0! WAT?
}
auto foo(int i) {
// Trivial for this demonstration
return i;
}
After struggling for too long to admit, I realized that 10,000 is not
"ten thousand" but "10 and 0". Ouch!
Ali
More information about the Digitalmars-d
mailing list