On Sunday, 14 June 2015 at 06:12:30 UTC, Ozan wrote:
Hallo!

Is it possible to create arrays which has more then one type,
f. ex. array[0] = 1; array[1] = "z"; array[2] = new clazz(), ....

I tried "Variant", but it slow down heavily my app.

Greetings,
Ozan

It's always going to be slower. To do this, every access to the array has to come with some amount of branching and/or and indirection (including an indirect function call if you do it the OOP way), which all have a cost, not to mention obstructing optimisation by the compiler.

It's possible that std.variant.Variant isn't as fast as it could be, but it's never going to be even close to zero-performance-cost.

Reply via email to