[Issue 2257] Template value parameters behave like alias parameters

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 5 14:57:00 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=2257


Stewart Gordon <smjg at iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg at iname.com


--- Comment #7 from Stewart Gordon <smjg at iname.com> 2012-02-05 14:56:56 PST ---
This might be related:
----------
struct DimensionedValue(Val, int Dim) {
    Val value;

    auto opMul(T)(T v) {
        return DimensionedValue!(typeof(value * T.init), Dim)(value * v);
    }
}

template isDimensionedValue(T : DimensionedValue!(V, D), V, int D) {
    enum bool isDimensionedValue = true;
}
template isDimensionedValue(T) {
    enum bool isDimensionedValue = false;
}

DimensionedValue!(int, 1) x;
//DimensionedValue!(double, 1) y;
pragma(msg, typeof(x * 2));
pragma(msg, isDimensionedValue!(typeof(x * 2)));
pragma(msg, typeof(x * 2.5));
pragma(msg, isDimensionedValue!(typeof(x * 2.5)));
----------
DimensionedValue!(int,1)
true
DimensionedValue!(double,Dim)
false
----------

Reinstating the declaration of y suppresses the bug.  As does using Dim + 0 in
opMul.

Is this another manifestation of the same bug, or does it warrant a separate
bug report?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list