Applying storage to type tuples
Daniel Keep
daniel.keep.lists at gmail.com
Sun Feb 8 23:44:41 PST 2009
Burton Radons wrote:
> I'm writing a couple of modules for dealing with database values (well really it's just storage of aggregates) in a native fashion from within D, using D 2.023. I have a tuple called FieldTypes which contains the D-side types. I'm trying to use it to implement opApply:
>
> int opApply (int delegate (FieldTypes) func)
>
> Unfortunately, this fails because the compiler only accepts the field types if they're references. But if I do this:
>
> int opApply (int delegate (ref FieldTypes) each)
>
> It seems that the delegate takes a reference to one type, which is a value tuple! For example it claims that, simplified, "function Table.opApply (int delegate (ref (string, string)) each) does not match parameter types (int delegate (ref string, ref string))".
>
> I've already implemented another opApply that takes a Line containing all the fields, but I'd like to have the expanded form as well if possible. Is it?
Yeah, I've run into this before. I solved it at the time using CTFE and
string mixins:
alias mixin(refDelegateFromTuple!(FieldTypes)) FieldTypesDg;
-- Daniel
More information about the Digitalmars-d-learn
mailing list