I'm writing a templated struct in D, which uses string mixin
s and compile time functions for some of its functionality. Basically, it is in this format:
string genCode(T)() {
// ...
}
struct MyTemplate(T) {
mixin(genCode!(T)());
// ...
}
Looking at this, genCode()
is clearly an implementation detail of my template class; making it public exposes logic which should really be private, and which could be subject to change. It also clutters the module's exported namespace.
When I try to make it private
, however, D throws an error. As far as I can tell, the expression in the string mixin
is evaluated in whatever scope MyTemplate
is instantiated in, which caused D to claim that the symbol genCode()
is not declared.
Is there any way around this? Do I just have to live with genCode()
as a public function, or is there some way I can hide it?