On 12/16/2015 06:14 PM, Andrei Alexandrescu wrote:
So, I wrote this beautiful BigO framework: <400 lines all told, clear
code, real nice. Then I got this cold shower:
void insertFrontMany(C, R)(C container, R range)
@BigO(complexity!(C.insertFront) * linearTime)
{
...
}
My hope being of course that for containers with linear insertion time
at the front I'll get quadratic, etc.
linear and quadratic in what?
The hitch is:
test.d(377): Error: undefined identifier 'C.insertFront'
So... attributes are currently not allowed to depend on template
parameters,
Yes, they are.
template bar(T){ @(T.str) auto bar(T t){ } }
struct A{ enum str="str"; }
static assert(__traits(getAttributes,bar!A)[0]=="str");
...
Seems to me this is a bug - different instantiations should have
different attributes etc. Is there any matter of principle making this
not work?
...
No, just a broken lowering in the parser.
auto bar(T)(T t)@(T.str){ }
should be the same as
template bar(T){ auto bar(T t)@(T.str){ } }
It's probably very easy to fix.