TemplateInstance.isDiscardable

class TemplateInstance
final
bool
isDiscardable
()

Return Value

Type: bool

true if the instances' innards are discardable.

The idea of this function is to see if the template instantiation can be 100% replaced with its eponymous member. All other members can be discarded, even in the compiler to free memory (for example, the template could be expanded in a region allocator, deemed trivial, the end result copied back out independently and the entire region freed), and can be elided entirely from the binary.

The current implementation affects code that generally looks like:

template foo(args...) {
    some_basic_type_or_string helper() { .... }
    enum foo = helper();
}

since it was the easiest starting point of implementation but it can and should be expanded more later.

Suggestion Box / Bug Report