On Wednesday, 10 May 2017 at 17:12:11 UTC, Carl Sturtivant wrote:
Here's the beginning of an interesting little experiment to
simulate reference variables using `alias this` to disguise a
pointer as a reference. Could add a destructor to set the
pointer to null when a reference goes out of scope.
...
I've used this code for similar purpose:
alias TextEditorSettingsRef = TextEditorSettings*;
alias TextEditorSettingsConstRef = const(TextEditorSettings)*;
struct TextEditorSettings
{}
But you need to have two aliases (templates) for const and
non-const refs, since using:
const TextEditorSettingsRef editor;
does:
const(TextEditorSettings*)
not
const(TextEditorSettings)*
What do you think?