Created
August 13, 2010 13:03
-
-
Save sinfu/522840 to your computer and use it in GitHub Desktop.
明示的フォワードでも駄目なんだね
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() | |
{ | |
enum s = S(S.F(42)); | |
alias W!( s .a ) k3; // 'a' | |
// alias W!(wantValue(s .a)) k4; // Error: this for a needs to be type F not type A | |
alias W!( s.forward.a ) k1; // 'a' | |
alias W!(wantValue(s.forward.a)) k2; // '42' | |
} | |
alias W!(S .square) symA; | |
alias W!(S.forward.square) symB; | |
static assert(__traits(isSame, symA, symB)); | |
template W(alias k) { pragma(msg, k); } | |
struct S | |
{ | |
struct F | |
{ | |
int a; | |
int square(int n) { return n*n; } | |
real square(real n) { return n*n; } | |
static @property int boo() { return 42; } | |
} | |
F forward; | |
/+ | |
@property void forward(F fwd); | |
@property F forward( ) { return F(a); } | |
+/ | |
alias forward.a a; | |
alias forward.square square; | |
alias forward.boo boo; | |
//alias forward this; | |
} | |
T wantValue(T)(T v) { return v; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment