Array of CodeDocuments?

Does anyone know why its not possible to create an Array of CodeDocuments? When trying to compile this:

Array<CodeDocument> arrayOfDocs;

CodeDocument doc;


I get: Call to deleted constructor of 'juce::CodeDocument' from with the below line of the array add function:

new (data.elements + numUsed++) ElementType (newElement);

Seems that this is due to the CodeDocument not having an copy constructor and not getting one due to:


being defined in its declaration... I guess there is a good reason for that, otherwise Jules would not put it in. I guess I could wrap the code document by another class with something hacky in it:

        class CodeDocument2



            CodeDocument2() {};

            CodeDocument2(CodeDocument2 const &ref)




            CodeDocument doc;


Will keep thinking about if what I'm doing is the right approach anyways though. 

Have you tried using an OwnedArray ?


Yes, OwnedArray would be the one to use. Array is designed for classes that have by-value semantics, and something like a CodeDocument definitely isn't a pass-by-value object!

Thanks guys! I was thinking the same thing last night when I decided to step away from the project, and funny enough I was using an owned array in the same class.