On Friday, 20 December 2013 at 08:03:26 UTC, FreeSlave wrote:
Make first read function templated too like this:

long read()( ubyte* bytes, long len )

In fact, there are workarouns. But why the order of the declarations has an effect on the compilation result.

Namely, if the templated overloaded function goes after the non-templated one then the compilation fails.
FAILED:
long read( ubyte* bytes, long len ) { return 0; }
void read(T)( ref T val ) { read(cast(ubyte*)&val, cast(long)val.sizeof); }

Otherwise, if the templated overloaded function goes before the non-templated one then the compilation is successful.
SUCCEEDED:
void read(T)( ref T val ) { read(cast(ubyte*)&val, cast(long)val.sizeof); }
long read( ubyte* bytes, long len ) { return 0; }

Why?

Reply via email to