[Issue 11946] "need 'this' to access member" when passing field to template parameter
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 23 20:16:32 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11946
--- Comment #17 from Kenji Hara <k.hara.pg at gmail.com> 2014-01-23 20:16:30 PST ---
(In reply to comment #16)
> OK... but then why does your suggestion in comment#1 work? If it is as you say,
> then "static" should have no effect on free functions, regardless if they are
> in a template or not, right?
Again, 'f' is not a free function, it is a function template that declared in
module level. Therefore, instantiated function f!x will become nested if inner
static attribute does not exist.
// static int f(A...)() { return 0; } is equivalent with
static template f(A...) { int f() { return 0; } }
struct S { int x;
enum y = f!x // f!x is equivalent with member function of S.
}
On the other hand:
template f(A...) { static int f() { return 0; } }
struct S { int x;
enum y = f!x // f!x is equivalent with 'static' member function of S.
}
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list