Template parameter-dependent attributes

Manu via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 23 19:26:16 PST 2015


On 17 December 2015 at 03:14, Andrei Alexandrescu via Digitalmars-d
<digitalmars-d at puremagic.com> 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. The hitch is:
>
> test.d(377): Error: undefined identifier 'C.insertFront'
>
> So... attributes are currently not allowed to depend on template parameters,
> which is a serious damper on enthusiasm.

Remember that time I complained about this more than 2 and a half years ago?

https://issues.dlang.org/show_bug.cgi?id=10193

> Seems to me this is a bug - different instantiations should have different
> attributes etc. Is there any matter of principle making this not work?

Seems like a bug to me too, since you can express it with a fully
expanded template, just not with the template syntax you actually use.


More information about the Digitalmars-d mailing list