Skip to content

Instantly share code, notes, and snippets.

@theoremoon
Created May 6, 2018 10:53
Show Gist options
  • Select an option

  • Save theoremoon/a22e023f3bc287644642c7813922eb94 to your computer and use it in GitHub Desktop.

Select an option

Save theoremoon/a22e023f3bc287644642c7813922eb94 to your computer and use it in GitHub Desktop.
再帰(?)でテンプレート引数を貯める例
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