public alias to private template implementation

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Tue Sep 17 01:47:15 PDT 2013


On 16/09/13 23:00, monarch_dodra wrote:
> Question 1: Is this the correct behavior? I'd have expected that if my alias is
> public, it would allow any one from outside to make the call correctly.

See: http://d.puremagic.com/issues/show_bug.cgi?id=10996

> Question 2: Is there a "correct" way to do this? I possible, I'd want to avoid
> "nesting" the template, eg:
> auto fun(){return Impl!int();}
> As that would:
> a) require more typing ^^
> b) incur an extra function call in non-inline
> c) if at all possible, I actually need "fun" to be a template, so that it can be
> inlined.

Indeed, I used that workaround of manually nesting the functions in some code of 
mine:
https://github.com/WebDrake/Dgraph/blob/master/dgraph/graph.d#L492-L516

... but that's not a general solution, I was able to tolerate it because it's a 
limited and predictable set of instructions.

Jacob Carlborg suggested using opDispatch (cf. how it's done in Proxy), which 
should automate the "nesting" of template functions.  I avoided it simply 
because in my case I thought that doing it manually would be less hassle than 
getting opDispatch set up to cover every possible case, but depending on your 
use case it might be the better option.


More information about the Digitalmars-d-learn mailing list