View mode: basic / threaded / horizontal-split · Log in · Help
November 10, 2007
[Issue 1659] New: template alias parameters are chosen over all but exact matches.
http://d.puremagic.com/issues/show_bug.cgi?id=1659

          Summary: template alias parameters are chosen over all but exact
                   matches.
          Product: D
          Version: 2.007
         Platform: PC
       OS/Version: Linux
           Status: NEW
         Keywords: wrong-code
         Severity: normal
         Priority: P2
        Component: DMD
       AssignedTo: bugzilla@digitalmars.com
       ReportedBy: spunit262@yahoo.com


For example say I have a class foo and a class diverged from foo called bar,
and I have a template specialization for foo and a template by the same name
that takes an alias. I instantiate that template with bar and get the alias
version. The spec say that the most specialized version is chosen, but isn't an
alias template the least specialized type of template, even more so than a
unspecialized template that takes a generic type?


--
November 10, 2007
[Issue 1659] template alias parameters are chosen over all but exact matches.
http://d.puremagic.com/issues/show_bug.cgi?id=1659





------- Comment #1 from spunit262@yahoo.com  2007-11-10 13:28 -------
Created an attachment (id=208)
--> (http://d.puremagic.com/issues/attachment.cgi?id=208&action=view)
an example


--
April 03, 2009
[Issue 1659] template alias parameters are chosen over all but exact matches.
http://d.puremagic.com/issues/show_bug.cgi?id=1659





------- Comment #2 from gide@nwawudu.com  2009-04-03 16:04 -------
Including original attachment in this comments. Issue looks similar to BUG 918.

import std.stdio;

typedef char ctd;
class Foo { }
class Bar : Foo { }

void main()
{
   Baz!(char)(); /* regular template version used only because
                  * template alias parameters reject basic types. */
   Baz!(ctd)(); // alias version used
   Baz!(Foo)(); // Foo version used
   Baz!(Bar)(); // alias version used
}

void Baz(T)()
{
   writefln("regular template version called with ", T.stringof);
}

void Baz(T : Foo)()
{
   writefln("foo specialization called with ", T.stringof);
}

void Baz(alias T)()
{
   writefln("alias version called with ", T.stringof);
}


--
January 25, 2010
[Issue 1659] template alias parameters are chosen over all but exact matches.
http://d.puremagic.com/issues/show_bug.cgi?id=1659


Witold Baryluk <baryluk@smp.if.uj.edu.pl> changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
                CC|                            |baryluk@smp.if.uj.edu.pl


--- Comment #3 from Witold Baryluk <baryluk@smp.if.uj.edu.pl> 2010-01-24 21:09:54 PST ---
This problem is still present in DMD 2.039.
It looks that from unknown reasons bug918 is solved (nobody comented what was
source of regression and dissapiring of it). Probably it is different aspect
here of template matching.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home