Specialization - Major hole in the spec?
Jonathan M Davis
jmdavisProg at gmx.com
Thu Jan 5 17:04:26 PST 2012
On Friday, January 06, 2012 01:47:03 Timon Gehr wrote:
> On 01/06/2012 12:22 AM, Peter Alexander wrote:
> > On 5/01/12 9:37 PM, Trass3r wrote:
> >> On Thursday, 5 January 2012 at 15:11:13 UTC, Timon Gehr wrote:
> >>> On 01/05/2012 10:14 AM, Peter Alexander wrote:
> >>>> In any case, it is surely a bug. I have *explicitly* specified
> >>>> that T
> >>>> must be int, yet it has called a version with T == float.
> >>>
> >>> No it has called a version with T : float. ":" means "implicitly
> >>> converts to". This is by design.
> >>
> >> I think we should rename this to something like 'type constraint'
> >> instead of specialization (and add the explanation that it means
> >> implicitly converts). As this thread shows C++ programmers will be
> >> confused otherwise.
> >
> > Upon further investigation, the website disagrees with what you've said.
> >
> > http://dlang.org/templates-revisited.html
>
> Interesting. I think this is an error in the website. Walter?
I'm certain that it's an error in the website. : means implicitly convertible,
no matter by what means that implicit conversion occurs (built-in, alias this,
etc.). You use == if you want the types to match exactly (including modifiers
such as const or shared).
- Jonathan M Davis
More information about the Digitalmars-d
mailing list