Arrays and complicated objects

I don't suppose there's some fancy stuff that could be done to make this problem: 

  • The Array class can be used to hold simple, non-polymorphic objects as well as primitive types - to do so, the class must fulfil these requirements:
  • [...]
  • it must be able to be relocated in memory by a memcpy without this causing any problems - so objects whose functionality relies on external pointers or references to themselves can not be used.

A compile time error rather than an obscure crash?  

Not that I've just spent three hours chasing my tail on a stupid self-inflicted bug ... appears you can't put std::functions<> into juce::Array<> and expect it to work.

Off to understand the differences between vector and Array and check I've actually solved my problem...

Actually, now that a lot of classes have C++11 move operators, I could probably start to remove that restriction without killing performance. Will revisit it sometime soon.

In the meantime, std::vector or OwnedArray would do the job.

Bit surprising that std::function would have a problem though! Its implementation must contain some kind of pointer to an object that has a reference back to the std::function object itself, which is surprising as I'd have expected it to be simpler than that.

I was a bit surprised at the insides of it too.  But it has a destructor that goes around deleting some point to an object of type *__Base

I've gone for std::vector.