typename
まずはC++.
#include <iostream> template <typename T> struct A { typename T::X v; }; struct B { typedef int X; }; void main() { A<B> x; x.v = 42; std::cout << x.v << std::endl; }
次にD言語.
import std.stdio; struct A(T) { T.X v; } struct B { alias int X; } void main() { A!B x; x.v = 42; writeln(x.v); }
何でDはtypenameのようなものがいらないのかなと思った.
むしろC++の方は,そこに型ではなく値が現れる場合があるのだろうか?
思いつかないんだけど.