Example program:
struct T(uint x) {
pragma(msg, "Instantiated at ", x);
static assert(x == 0);
}
static assert(is(T!0));
static assert(is(T!0));
static assert(!is(T!1));
static assert(!is(T!1)); // redoes all the work :-(
prints:
Instantiated at 0u
Instantiated at 1u
Instantiated at 1u
Sometimes, detecting an error in template instantiation can be costly.
If the compiler memoized not only template instantiation successes but also failures, it can save compilation time and improve output when pragma(msg, ...) are involved.
Comment #1 by robert.schadek — 2024-12-13T19:19:05Z