Accessing static data of functions
Ali Çehreli
acehreli at yahoo.com
Thu Oct 14 21:08:51 UTC 2021
On 10/14/21 7:21 AM, Ogi wrote:
> is there any way to access the types defined inside
> in function to get/set their static members?
Possible through instances of those types (not through type names
because those type names are not visible from the outside):
auto foo() {
struct S {
static int s;
}
return S();
}
void main() {
auto s = foo();
s.s = 42;
foo().s++;
assert(foo().s == 43);
}
Ali
More information about the Digitalmars-d
mailing list