Created
May 6, 2018 10:53
-
-
Save theoremoon/a22e023f3bc287644642c7813922eb94 to your computer and use it in GitHub Desktop.
再帰(?)でテンプレート引数を貯める例
This file contains hidden or 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
| struct A { | |
| int x; | |
| } | |
| void a(string name, T)(ref T v) | |
| { | |
| mixin("v."~name) = 1; | |
| } | |
| import std.stdio; | |
| auto f(string n)() { | |
| class B_(string[] names = []) | |
| { | |
| auto f(string n)() { | |
| return new B_!(names ~ n); | |
| } | |
| void b() { | |
| writeln(names); | |
| } | |
| } | |
| return new B_!([n]); | |
| } | |
| void main() | |
| { | |
| auto b = f!("HELLO") | |
| .f!("WORLD") | |
| .f!("WORLD") | |
| .f!("WORLD") | |
| .f!("WORLD") | |
| .f!("WORLD") | |
| .f!("!"); | |
| b.b(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment