On 10 June 2012 03:42, Jonathan M Davis <[email protected]> wrote: > On Sunday, June 10, 2012 02:26:36 timotheecour wrote: > > What is the recommended approach when we have no control over > > classes A or B (cf from 3rd party) to convert A to B? > > It seems UFCS doesn't work in that case. > > Could you please provide an example code? > > Thanks! > > If you want to convert between two types and you don't control the > definitions > of either, and neither of them have any functions which will convert from > one > to the (including constructors, opCast, etc.), then you're just going to > have > to write a function to do it. It's not gonig to work with std.conv.to or > casting, but you can write such a function just like you can write any > other > function. > > A convertBToA(B b) {...} > > I don't think tha there's anything else that you _can_ do. >
That's very problematic for generic programming :/
