<div class="gmail_quote">On Mon, Jul 19, 2010 at 22:01, torhu <span dir="ltr">&lt;no@spam.invalid&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5"><br>

<br></div></div>
I wasn&#39;t able to make it work.  </blockquote><div><br>Me too :(<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">The compiler probably sees delegates as something that just can&#39;t be created at compile time, since no runtime contexts exist then.  Which is reasonable.<br>
</blockquote><div><br>Can you initialize pointers in general, at compile-time?<br><br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


Maybe one of those templates that turn functions into delegates will work?  </blockquote><div><br>I had the same idea and tried to use std.functional.toDelegate, but to no avail.<br><br>enum moo = ()  {return 1;};<br><br>
struct foo {<br>   int delegate( ) dg = toDelegate(moo);<br>}<br><br>Error: forward reference to inferred return type of function call toDelegate(delegate int()|<br><br>int moo() { return 1;}<br><br>struct foo {<br>   int delegate( ) dg = toDelegate(&amp;moo);<br>
}<br><br>Error: forward reference to inferred return type of function call toDelegate((&amp; moo))|<br><br>&#39;auto&#39; strikes again :(<br>I came to hate these forward reference errors. That and the fact that auto functions do not appear in the docs, that&#39;s enough for me to avoid auto as much as possible for functions.<br>
<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Otherwise I guess you&#39;re back to using a factory function for initializing instances.<br>

<br>
Maybe just checking for null pointers before calling those delegates ends up being the easiest solution.<br></blockquote><div><br><br>Philippe<br> <br></div></div><br>