November 10, 2007

           Summary: template alias parameters are chosen over all but exact
           Product: D
           Version: 2.007
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD

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

------- Comment #1 from  2007-11-10 13:28 -------
Created an attachment (id=208)
 --> (
an example


April 03, 2009

------- Comment #2 from  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

Witold Baryluk <> changed:

           What    |Removed                     |Added
                 CC|                            |

--- Comment #3 from Witold Baryluk <> 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:
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home