JUCE array contains invalid operands error

Whenever I try to call the Array contains function on a struct I have created I get an error

/Users/dp9443/Documents/Princeton/bitKlavier/bk_JUCE/bitKlavier/JuceLibraryCode/modules/juce_core/containers/juce_Array.h:407:34: Invalid operands to binary expression ('const Modifications::PianoMap' and 'const Modifications::PianoMap')

Here is the struct

typedef struct PianoMap
    {
        int pianoTarget;
        Keymap::PtrArr keymaps;
    }PianoMap;
    Array<PianoMap>             pianoMaps;

I assume it has something to do with the struct not operating properly as a pointer?

Any ideas what this might be?

juce::Array stores PianoMap objects, not pointers to them. So the PianoMap struct needs to support various operations like copy constructor/assignment, the equality operator etc in order to work with the Array methods. (You sometimes get the object copying stuff “for free” from the compiler, but never the == operator, which I am assuming the Array::contains method will need.)

1 Like