New operators opStaticIndex and friends

Exil Exil at gmall.com
Wed May 15 01:42:57 UTC 2019


On Wednesday, 15 May 2019 at 01:07:10 UTC, Q. Schroll wrote:
> On Tuesday, 14 May 2019 at 16:15:20 UTC, H. S. Teoh wrote:
>> On Tue, May 14, 2019 at 03:49:51PM +0000, Q. Schroll via 
>> Digitalmars-d wrote:
>>> I whish, D has these operators:
>>> 
>>> opStaticIndex
>>> opStaticIndexAssign
>>> opStaticIndexOpAssign
>>> opStaticSlice
>>> 
>>> When used, they look the same way as opIndex and friends, but 
>>> the stuff between [ and ] would be bound to template 
>>> parameters (instead of runtime parameters) and be known at 
>>> compile time. Basically, this allows to implement static 
>>> indexing the same way it is possible for an AliasSeq.
>>
>> +1.  I'd love to have this feature too.
>>
>>
>> T
>
> I've made it into a DIP: https://github.com/dlang/DIPs/pull/155

Does it need to be called opStaticIndex? Could it just be called 
opIndex and require the specific template arguments. If you 
define opIndex(int)() now, it will never be called right (unless 
you specifically invoke it)?


More information about the Digitalmars-d mailing list