opApply and const

Arne Ludwig via Digitalmars-d digitalmars-d at puremagic.com
Thu May 8 22:26:10 PDT 2014


Hello,

when using opApply it seems natural to have two versions: one 
normal and one const. My problem is that I cannot find a way to 
describe both versions with one code block. Since there could be 
a number of basic variants with different numbers of delegate 
arguments this can lead to serious code duplication.

This problem was discussed years ago:

http://www.digitalmars.com/d/archives/digitalmars/D/opApply_and_const_63436.html

Small example:

http://pastebin.com/kRrPp6Yg

In that example I need four times (mostly) the same code. There 
should be any way around that. Has someone ideas?


More information about the Digitalmars-d mailing list