Purpose of template DECLARE_HANDLE in druntime

Steven Schveighoffer schveiguy at gmail.com
Thu Jan 31 21:05:57 UTC 2019


On 1/31/19 3:51 PM, Andre Pany wrote:
> Hi,
> 
> I noticed in druntime this template is used often:
> 
> package template DECLARE_HANDLE(string name, base = HANDLE) {
>      mixin ("alias " ~ base.stringof ~ " " ~ name ~ ";");
> 
> The disadvantage is, IDEs like IntelliJ are not able to find the symbols 
> using this template e.g.
> mixin DECLARE_HANDLE!("SC_HANDLE");
> 
> What is the benefit of this template?
> Why can't we just use
> alias HANDLE SC_HANDLE;
> 

Most likely it's a direct translation from a C preprocessor macro.

-Steve


More information about the Digitalmars-d-learn mailing list