Type inference and overloaded functions

Kenji Hara k.hara.pg at gmail.com
Tue Dec 10 02:19:45 PST 2013


On Tuesday, 10 December 2013 at 09:28:27 UTC, Jonathan M Davis 
wrote:
> On Tuesday, December 10, 2013 10:10:22 Namespace wrote:
> auto staticLiteral(T, size_t n)(T[n] literal)
> {
>     return literal;
> }
>
> auto staticArray = staticLiteral([1, 2, 3, 4]);

Why do you think this is possible? If an array literal should 
match _only_ dynamic array types, it would never work.

Because compiler will try to match array literal to static array 
T[n]. The feature which I have described is working here.

Kenji Hara


More information about the Digitalmars-d-learn mailing list