module pind.samples.ja.functions_more.functions_more_9; import std.stdio; size_t counter; int foo() { if (!__ctfe) { // このコードは実行時に実行される ++counter; } return 42; } void main() { enum i = foo(); auto j = foo(); writefln("foo is called %s times.", counter); }