www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1659] New: template alias parameters are chosen over all but exact matches.

reply d-bugmail puremagic.com writes:
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?


-- 
Nov 10 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1659






Created an attachment (id=208)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=208&action=view)
an example


-- 
Nov 10 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1659






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);
}


-- 
Apr 03 2009
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Jan 24 2010