On Thursday, 11 January 2018 at 08:56:11 UTC, ChangLong wrote:
When I try add some sub type for struct with mixin template,
seems there is no way to hidden the private type.
Is there a way to hidden type from mix template like Voldemort
type ?
fake code:
mix template TypeX () {
alias This = typeof(this);
static struct Unique {
This* _ptr ;
}
static struct Helper {
private Unique data;
}
alias TypeX = {
alias PublicName = Helper ;
}
}
struct Node {
mixin TypeX!();
PublicName helper;
}
Hi, can you explain a bit more? The question is not entirely
clear to me. Can you mixin a struct of type PublicName and just
hide everything in there?
mixin template TypeX() {
struct PublicName {
private alias This = typeof(this);
private struct Unique {
This* _ptr;
}
private Unique _data;
alias _data this;
}
}
void main(string[] args) {
mixin TypeX;
PublicName helper;
helper._ptr.writeln;
}
Cheers