[Issue 16410] attribute inference inside templated classes
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Sun Aug 21 07:11:48 PDT 2016
    
    
  
https://issues.dlang.org/show_bug.cgi?id=16410
b2.temp at gmx.com changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|rejects-valid               |
                 CC|                            |b2.temp at gmx.com
           Severity|major                       |enhancement
--- Comment #2 from b2.temp at gmx.com ---
This is an enhancement request not a bug report. 
The member function itself is not a template and since attribs are infered only
for templated functions the error message is correct. 
With "auto" return type the member function becomes a template so it works. It
would also work with a template this parameter or with empty CT parameters.
°°°°°°°°°°°°°°°°°°°°°°°
class Bar(T)
{
    T t;
    ulong a()(){return t.length;}
    ulong b(this T)(){return t.length;}
    auto c(){return t.length;}
}
@nogc void main()
{
    import std.experimental.allocator;
    import std.experimental.allocator.mallocator;
    auto alloc = Mallocator.instance;
    auto a = alloc.make!(Bar!string).a;
    auto b = alloc.make!(Bar!string).b;
    auto c = alloc.make!(Bar!string).c;
}
°°°°°°°°°°°°°°°°°°°°°°°
Definitively not a "rejects-valid".
--
    
    
More information about the Digitalmars-d-bugs
mailing list