diff --git a/examples/DSPDemo/Source/MainComponent.cpp b/examples/DSPDemo/Source/MainComponent.cpp index 77968ba14b..08fc4d0d48 100644 --- a/examples/DSPDemo/Source/MainComponent.cpp +++ b/examples/DSPDemo/Source/MainComponent.cpp @@ -221,7 +221,7 @@ void MainContentComponent::setupDemoColours() if (xml != nullptr) { auto colourSchemeTree = ValueTree::fromXml (*xml); - auto& scheme = codeEditor.getColourScheme(); + CodeEditorComponent::ColourScheme scheme (codeEditor.getColourScheme()); for (auto& type : scheme.types) { @@ -230,6 +230,8 @@ void MainContentComponent::setupDemoColours() if (colour.isValid()) type.colour = Colour::fromString (colour ["colour"].toString()); } + + codeEditor.setColourScheme (scheme); } codeEditor.setScrollbarThickness (6); diff --git a/examples/Demo/Source/Demos/WavefrontObjParser.h b/examples/Demo/Source/Demos/WavefrontObjParser.h index 02c85f67e5..6d3eb9517c 100644 --- a/examples/Demo/Source/Demos/WavefrontObjParser.h +++ b/examples/Demo/Source/Demos/WavefrontObjParser.h @@ -249,7 +249,7 @@ private: }; static Shape* parseFaceGroup (const Mesh& srcMesh, - const Array& faceGroup, + Array& faceGroup, const Material& material, const String& name) { diff --git a/examples/NetworkGraphicsDemo/Source/MasterComponent.h b/examples/NetworkGraphicsDemo/Source/MasterComponent.h index d3eaea7668..c260e759cb 100644 --- a/examples/NetworkGraphicsDemo/Source/MasterComponent.h +++ b/examples/NetworkGraphicsDemo/Source/MasterComponent.h @@ -369,7 +369,7 @@ private: canvas.clients.add ({ c.name, c.centre, c.scaleFactor }); } - Client* getClient (const String& name) const + const Client* getClient (const String& name) const { for (auto& c : clients) if (c.name == name) @@ -378,6 +378,11 @@ private: return nullptr; } + Client* getClient (const String& name) + { + return const_cast (static_cast (*this).getClient (name)); + } + //============================================================================== void oscMessageReceived (const OSCMessage& message) override { diff --git a/examples/NetworkGraphicsDemo/Source/SharedCanvas.h b/examples/NetworkGraphicsDemo/Source/SharedCanvas.h index 842d05650c..5688c7bb22 100644 --- a/examples/NetworkGraphicsDemo/Source/SharedCanvas.h +++ b/examples/NetworkGraphicsDemo/Source/SharedCanvas.h @@ -455,7 +455,7 @@ struct BlockPacketiser while (remaining > 0) { - const int num = jmin (maxBlockSize, remaining); + auto num = (int) jmin (maxBlockSize, remaining); blocks.add (MemoryBlock (addBytesToPointer (data.getData(), offset), (size_t) num)); offset += num; remaining -= num; diff --git a/examples/OSCMonitor/Source/OSCLogListBox.h b/examples/OSCMonitor/Source/OSCLogListBox.h index 3cc04d83de..e29fc648ad 100644 --- a/examples/OSCMonitor/Source/OSCLogListBox.h +++ b/examples/OSCMonitor/Source/OSCLogListBox.h @@ -76,8 +76,8 @@ public: if (! message.isEmpty()) { - for (OSCArgument* arg = message.begin(); arg != message.end(); ++arg) - addOSCMessageArgument (*arg, level + 1); + for (auto& arg : message) + addOSCMessageArgument (arg, level + 1); } triggerAsyncUpdate(); @@ -92,12 +92,12 @@ public: + "- osc bundle, time tag = " + timeTag.toTime().toString (true, true, true, true)); - for (OSCBundle::Element* element = bundle.begin(); element != bundle.end(); ++element) + for (auto& element : bundle) { - if (element->isMessage()) - addOSCMessage (element->getMessage(), level + 1); - else if (element->isBundle()) - addOSCBundle (element->getBundle(), level + 1); + if (element.isMessage()) + addOSCMessage (element.getMessage(), level + 1); + else if (element.isBundle()) + addOSCBundle (element.getBundle(), level + 1); } triggerAsyncUpdate(); diff --git a/examples/OpenGLAppExample/Source/Resources/WavefrontObjParser.h b/examples/OpenGLAppExample/Source/Resources/WavefrontObjParser.h index 02c85f67e5..6d3eb9517c 100644 --- a/examples/OpenGLAppExample/Source/Resources/WavefrontObjParser.h +++ b/examples/OpenGLAppExample/Source/Resources/WavefrontObjParser.h @@ -249,7 +249,7 @@ private: }; static Shape* parseFaceGroup (const Mesh& srcMesh, - const Array& faceGroup, + Array& faceGroup, const Material& material, const String& name) { diff --git a/extras/Projucer/Source/CodeEditor/jucer_LiveBuildCodeEditor.h b/extras/Projucer/Source/CodeEditor/jucer_LiveBuildCodeEditor.h index 1cae43f414..9ed2c8e843 100644 --- a/extras/Projucer/Source/CodeEditor/jucer_LiveBuildCodeEditor.h +++ b/extras/Projucer/Source/CodeEditor/jucer_LiveBuildCodeEditor.h @@ -234,7 +234,7 @@ private: Array newClasses; if (childProcess != nullptr) - childProcess->getComponentList().globalNamespace.findClassesDeclaredInFile (newClasses, file); + const_cast (childProcess->getComponentList()).globalNamespace.findClassesDeclaredInFile (newClasses, file); for (int i = newClasses.size(); --i >= 0;) if (! newClasses.getUnchecked(i)->getInstantiationFlags().canBeInstantiated()) diff --git a/extras/Projucer/Source/LiveBuildEngine/jucer_ClassDatabase.h b/extras/Projucer/Source/LiveBuildEngine/jucer_ClassDatabase.h index 579e380eae..aefbbc6fc9 100644 --- a/extras/Projucer/Source/LiveBuildEngine/jucer_ClassDatabase.h +++ b/extras/Projucer/Source/LiveBuildEngine/jucer_ClassDatabase.h @@ -291,15 +291,20 @@ struct ClassDatabase return classDeclaration; } - MemberInfo* findMember (const String& memberName) const + const MemberInfo* findMember (const String& memberName) const { - for (MemberInfo& m : members) + for (auto& m : members) if (m.getName() == memberName) return &m; return nullptr; } + MemberInfo* findMember (const String& memberName) + { + return const_cast (static_cast(*this).findMember (memberName)); + } + const MethodInfo* getDefaultConstructor() const { for (const MethodInfo& m : methods) @@ -340,15 +345,15 @@ struct ClassDatabase if (m->definition.isValid()) return m->definition.file; - for (MethodInfo& m : methods) + for (auto& m : methods) if (m.definition.isValid() && File (m.definition.file).hasFileExtension ("cpp;mm")) return m.definition.file; - for (MethodInfo& m : methods) + for (auto& m : methods) if ((m.flags & MethodInfo::isConstructor) != 0 && m.definition.isValid()) return m.definition.file; - for (MethodInfo& m : methods) + for (auto& m : methods) if (m.definition.isValid() && File (m.definition.file).exists()) return m.definition.file; @@ -380,9 +385,9 @@ struct ClassDatabase if (other.classDeclaration.isValid()) classDeclaration = other.classDeclaration; - for (const MemberInfo& m : other.members) + for (auto& m : other.members) { - if (MemberInfo* existing = findMember (m.getName())) + if (auto* existing = findMember (m.getName())) existing->mergeWith (m); else members.add (m); @@ -496,14 +501,14 @@ struct ClassDatabase return false; } - Class* findClass (const String& className) const + const Class* findClass (const String& className) const { - for (Class& c : components) + for (auto& c : components) if (c.getName() == className) return &c; - for (const auto& n : namespaces) - if (Class* c = n.findClass (className)) + for (auto& n : namespaces) + if (auto* c = n.findClass (className)) return c; return nullptr; @@ -511,19 +516,19 @@ struct ClassDatabase const MemberInfo* findClassMemberInfo (const String& className, const String& memberName) const { - if (const Class* classInfo = findClass (className)) + if (auto* classInfo = findClass (className)) return classInfo->findMember (memberName); return nullptr; } - void findClassesDeclaredInFile (Array& results, const File& file) const + void findClassesDeclaredInFile (Array& results, const File& file) { - for (Class& c : components) + for (auto& c : components) if (c.isDeclaredInFile (file)) results.add (&c); - for (const auto& n : namespaces) + for (auto& n : namespaces) n.findClassesDeclaredInFile (results, file); } @@ -553,7 +558,7 @@ struct ClassDatabase components.getReference (existing).mergeWith (c); } - Namespace* findNamespace (const String& targetName) const + Namespace* findNamespace (const String& targetName) { for (auto& n : namespaces) if (n.name == targetName) @@ -593,13 +598,13 @@ struct ClassDatabase namespaces.swapWith (other.namespaces); } - void nudgeAllCodeRanges (const String& file, int index, int delta) const + void nudgeAllCodeRanges (const String& file, int index, int delta) { for (auto& c : components) c.nudgeAllCodeRanges (file, index, delta); for (auto& n : namespaces) n.nudgeAllCodeRanges (file, index, delta); } - void fileContentChanged (const String& file) const + void fileContentChanged (const String& file) { for (auto& c : components) c.fileContentChanged (file); for (auto& n : namespaces) n.fileContentChanged (file); diff --git a/extras/Projucer/Source/LiveBuildEngine/jucer_ErrorList.h b/extras/Projucer/Source/LiveBuildEngine/jucer_ErrorList.h index 637d019de5..60cfe34ecf 100644 --- a/extras/Projucer/Source/LiveBuildEngine/jucer_ErrorList.h +++ b/extras/Projucer/Source/LiveBuildEngine/jucer_ErrorList.h @@ -42,7 +42,7 @@ struct ErrorList : public ChangeBroadcaster } else { - for (DiagnosticMessage& d : messages) + for (auto& d : messages) if (d.isError()) dest.add (d); } diff --git a/extras/Projucer/Source/Settings/jucer_AppearanceSettings.cpp b/extras/Projucer/Source/Settings/jucer_AppearanceSettings.cpp index f9a24dddbc..6087bbbc1f 100644 --- a/extras/Projucer/Source/Settings/jucer_AppearanceSettings.cpp +++ b/extras/Projucer/Source/Settings/jucer_AppearanceSettings.cpp @@ -40,11 +40,11 @@ AppearanceSettings::AppearanceSettings (bool updateAppWhenChanged) CPlusPlusCodeTokeniser tokeniser; CodeEditorComponent editor (doc, &tokeniser); - const CodeEditorComponent::ColourScheme cs (editor.getColourScheme()); + CodeEditorComponent::ColourScheme cs (editor.getColourScheme()); for (int i = cs.types.size(); --i >= 0;) { - CodeEditorComponent::ColourScheme::TokenType& t = cs.types.getReference(i); + auto& t = cs.types.getReference(i); getColourValue (t.name) = t.colour.toString(); } diff --git a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp index 4b94437247..a0effbef68 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp +++ b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp @@ -80,8 +80,10 @@ MidiMessageSequence::MidiEventHolder* MidiMessageSequence::getEventPointer (int return list[index]; } -MidiMessageSequence::MidiEventHolder** MidiMessageSequence::begin() const noexcept { return list.begin(); } -MidiMessageSequence::MidiEventHolder** MidiMessageSequence::end() const noexcept { return list.end(); } +MidiMessageSequence::MidiEventHolder** MidiMessageSequence::begin() noexcept { return list.begin(); } +MidiMessageSequence::MidiEventHolder*const* MidiMessageSequence::begin() const noexcept { return list.begin(); } +MidiMessageSequence::MidiEventHolder** MidiMessageSequence::end() noexcept { return list.end(); } +MidiMessageSequence::MidiEventHolder*const* MidiMessageSequence::end() const noexcept { return list.end(); } double MidiMessageSequence::getTimeOfMatchingKeyUp (int index) const noexcept { diff --git a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h index 8f5e3f6994..05025a89e8 100644 --- a/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h +++ b/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h @@ -101,10 +101,12 @@ public: MidiEventHolder* getEventPointer (int index) const noexcept; /** Iterator for the list of MidiEventHolders */ - MidiEventHolder** begin() const noexcept; + MidiEventHolder** begin() noexcept; + MidiEventHolder*const* begin() const noexcept; /** Iterator for the list of MidiEventHolders */ - MidiEventHolder** end() const noexcept; + MidiEventHolder** end() noexcept; + MidiEventHolder*const* end() const noexcept; /** Returns the time of the note-up that matches the note-on at this index. If the event at this index isn't a note-on, it'll just return 0. diff --git a/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp b/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp index 3908af7c54..539b241979 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEInstrument.cpp @@ -231,7 +231,7 @@ void MPEInstrument::processMidiAllNotesOffMessage (const MidiMessage& message) } } } - else if (MPEZone* zone = zoneLayout.getZoneByMasterChannel (message.getChannel())) + else if (auto* zone = zoneLayout.getZoneByMasterChannel (message.getChannel())) { for (int i = notes.size(); --i >= 0;) { @@ -400,7 +400,7 @@ void MPEInstrument::updateDimension (int midiChannel, MPEDimension& dimension, M } //============================================================================== -void MPEInstrument::updateDimensionMaster (MPEZone& zone, MPEDimension& dimension, MPEValue value) +void MPEInstrument::updateDimensionMaster (const MPEZone& zone, MPEDimension& dimension, MPEValue value) { auto channels = zone.getNoteChannelRange(); @@ -441,7 +441,7 @@ void MPEInstrument::updateDimensionForNote (MPENote& note, MPEDimension& dimensi } //============================================================================== -void MPEInstrument::callListenersDimensionChanged (MPENote& note, MPEDimension& dimension) +void MPEInstrument::callListenersDimensionChanged (const MPENote& note, const MPEDimension& dimension) { if (&dimension == &pressureDimension) { listeners.call ([&] (Listener& l) { l.notePressureChanged (note); }); return; } if (&dimension == &timbreDimension) { listeners.call ([&] (Listener& l) { l.noteTimbreChanged (note); }); return; } @@ -555,7 +555,7 @@ int MPEInstrument::getNumPlayingNotes() const noexcept MPENote MPEInstrument::getNote (int midiChannel, int midiNoteNumber) const noexcept { - if (MPENote* note = getNotePtr (midiChannel, midiNoteNumber)) + if (auto* note = getNotePtr (midiChannel, midiNoteNumber)) return *note; return MPENote(); @@ -569,7 +569,7 @@ MPENote MPEInstrument::getNote (int index) const noexcept //============================================================================== MPENote MPEInstrument::getMostRecentNote (int midiChannel) const noexcept { - if (MPENote* note = getLastNotePlayedPtr (midiChannel)) + if (auto* note = getLastNotePlayedPtr (midiChannel)) return *note; return MPENote(); @@ -579,7 +579,7 @@ MPENote MPEInstrument::getMostRecentNoteOtherThan (MPENote otherThanThisNote) co { for (int i = notes.size(); --i >= 0;) { - const MPENote& note = notes.getReference (i); + auto& note = notes.getReference (i); if (note != otherThanThisNote) return note; @@ -589,11 +589,11 @@ MPENote MPEInstrument::getMostRecentNoteOtherThan (MPENote otherThanThisNote) co } //============================================================================== -MPENote* MPEInstrument::getNotePtr (int midiChannel, int midiNoteNumber) const noexcept +const MPENote* MPEInstrument::getNotePtr (int midiChannel, int midiNoteNumber) const noexcept { for (int i = 0; i < notes.size(); ++i) { - MPENote& note = notes.getReference (i); + auto& note = notes.getReference (i); if (note.midiChannel == midiChannel && note.initialNote == midiNoteNumber) return ¬e; @@ -602,8 +602,13 @@ MPENote* MPEInstrument::getNotePtr (int midiChannel, int midiNoteNumber) const n return nullptr; } +MPENote* MPEInstrument::getNotePtr (int midiChannel, int midiNoteNumber) noexcept +{ + return const_cast (static_cast (*this).getNotePtr (midiChannel, midiNoteNumber)); +} + //============================================================================== -MPENote* MPEInstrument::getNotePtr (int midiChannel, TrackingMode mode) const noexcept +const MPENote* MPEInstrument::getNotePtr (int midiChannel, TrackingMode mode) const noexcept { // for the "all notes" tracking mode, this method can never possibly // work because it returns 0 or 1 note but there might be more than one! @@ -616,12 +621,17 @@ MPENote* MPEInstrument::getNotePtr (int midiChannel, TrackingMode mode) const no return nullptr; } +MPENote* MPEInstrument::getNotePtr (int midiChannel, TrackingMode mode) noexcept +{ + return const_cast (static_cast (*this).getNotePtr (midiChannel, mode)); +} + //============================================================================== -MPENote* MPEInstrument::getLastNotePlayedPtr (int midiChannel) const noexcept +const MPENote* MPEInstrument::getLastNotePlayedPtr (int midiChannel) const noexcept { for (int i = notes.size(); --i >= 0;) { - MPENote& note = notes.getReference (i); + auto& note = notes.getReference (i); if (note.midiChannel == midiChannel && (note.keyState == MPENote::keyDown || note.keyState == MPENote::keyDownAndSustained)) @@ -631,15 +641,20 @@ MPENote* MPEInstrument::getLastNotePlayedPtr (int midiChannel) const noexcept return nullptr; } +MPENote* MPEInstrument::getLastNotePlayedPtr (int midiChannel) noexcept +{ + return const_cast (static_cast (*this).getLastNotePlayedPtr (midiChannel)); +} + //============================================================================== -MPENote* MPEInstrument::getHighestNotePtr (int midiChannel) const noexcept +const MPENote* MPEInstrument::getHighestNotePtr (int midiChannel) const noexcept { int initialNoteMax = -1; - MPENote* result = nullptr; + const MPENote* result = nullptr; for (int i = notes.size(); --i >= 0;) { - MPENote& note = notes.getReference (i); + const auto& note = notes.getReference (i); if (note.midiChannel == midiChannel && (note.keyState == MPENote::keyDown || note.keyState == MPENote::keyDownAndSustained) @@ -653,14 +668,19 @@ MPENote* MPEInstrument::getHighestNotePtr (int midiChannel) const noexcept return result; } -MPENote* MPEInstrument::getLowestNotePtr (int midiChannel) const noexcept +MPENote* MPEInstrument::getHighestNotePtr (int midiChannel) noexcept +{ + return const_cast (static_cast (*this).getHighestNotePtr (midiChannel)); +} + +const MPENote* MPEInstrument::getLowestNotePtr (int midiChannel) const noexcept { int initialNoteMin = 128; - MPENote* result = nullptr; + const MPENote* result = nullptr; for (int i = notes.size(); --i >= 0;) { - MPENote& note = notes.getReference (i); + auto& note = notes.getReference (i); if (note.midiChannel == midiChannel && (note.keyState == MPENote::keyDown || note.keyState == MPENote::keyDownAndSustained) @@ -674,6 +694,11 @@ MPENote* MPEInstrument::getLowestNotePtr (int midiChannel) const noexcept return result; } +MPENote* MPEInstrument::getLowestNotePtr (int midiChannel) noexcept +{ + return const_cast (static_cast (*this).getLowestNotePtr (midiChannel)); +} + //============================================================================== void MPEInstrument::releaseAllNotes() { diff --git a/modules/juce_audio_basics/mpe/juce_MPEInstrument.h b/modules/juce_audio_basics/mpe/juce_MPEInstrument.h index 82b62de4db..1605c5a839 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEInstrument.h +++ b/modules/juce_audio_basics/mpe/juce_MPEInstrument.h @@ -351,9 +351,9 @@ private: MPEDimension pitchbendDimension, pressureDimension, timbreDimension; void updateDimension (int midiChannel, MPEDimension&, MPEValue); - void updateDimensionMaster (MPEZone&, MPEDimension&, MPEValue); + void updateDimensionMaster (const MPEZone&, MPEDimension&, MPEValue); void updateDimensionForNote (MPENote&, MPEDimension&, MPEValue); - void callListenersDimensionChanged (MPENote&, MPEDimension&); + void callListenersDimensionChanged (const MPENote&, const MPEDimension&); MPEValue getInitialValueForNewNote (int midiChannel, MPEDimension&) const; void processMidiNoteOnMessage (const MidiMessage&); @@ -368,11 +368,16 @@ private: void handleTimbreLSB (int midiChannel, int value) noexcept; void handleSustainOrSostenuto (int midiChannel, bool isDown, bool isSostenuto); - MPENote* getNotePtr (int midiChannel, int midiNoteNumber) const noexcept; - MPENote* getNotePtr (int midiChannel, TrackingMode) const noexcept; - MPENote* getLastNotePlayedPtr (int midiChannel) const noexcept; - MPENote* getHighestNotePtr (int midiChannel) const noexcept; - MPENote* getLowestNotePtr (int midiChannel) const noexcept; + const MPENote* getNotePtr (int midiChannel, int midiNoteNumber) const noexcept; + MPENote* getNotePtr (int midiChannel, int midiNoteNumber) noexcept; + const MPENote* getNotePtr (int midiChannel, TrackingMode) const noexcept; + MPENote* getNotePtr (int midiChannel, TrackingMode) noexcept; + const MPENote* getLastNotePlayedPtr (int midiChannel) const noexcept; + MPENote* getLastNotePlayedPtr (int midiChannel) noexcept; + const MPENote* getHighestNotePtr (int midiChannel) const noexcept; + MPENote* getHighestNotePtr (int midiChannel) noexcept; + const MPENote* getLowestNotePtr (int midiChannel) const noexcept; + MPENote* getLowestNotePtr (int midiChannel) noexcept; void updateNoteTotalPitchbend (MPENote&); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MPEInstrument) diff --git a/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp b/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp index c8f670a4a4..54d3d6a6b0 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp +++ b/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.cpp @@ -74,7 +74,7 @@ int MPEZoneLayout::getNumZones() const noexcept return zones.size(); } -MPEZone* MPEZoneLayout::getZoneByIndex (int index) const noexcept +const MPEZone* MPEZoneLayout::getZoneByIndex (int index) const noexcept { if (zones.size() < index) return nullptr; @@ -82,6 +82,11 @@ MPEZone* MPEZoneLayout::getZoneByIndex (int index) const noexcept return &(zones.getReference (index)); } +MPEZone* MPEZoneLayout::getZoneByIndex (int index) noexcept +{ + return const_cast (static_cast (*this).getZoneByIndex (index)); +} + void MPEZoneLayout::clearAllZones() { zones.clear(); @@ -157,42 +162,62 @@ void MPEZoneLayout::processNextMidiBuffer (const MidiBuffer& buffer) } //============================================================================== -MPEZone* MPEZoneLayout::getZoneByChannel (int channel) const noexcept +const MPEZone* MPEZoneLayout::getZoneByChannel (int channel) const noexcept { - for (auto* zone = zones.begin(); zone != zones.end(); ++zone) - if (zone->isUsingChannel (channel)) - return zone; + for (auto& zone : zones) + if (zone.isUsingChannel (channel)) + return &zone; return nullptr; } -MPEZone* MPEZoneLayout::getZoneByMasterChannel (int channel) const noexcept +MPEZone* MPEZoneLayout::getZoneByChannel (int channel) noexcept { - for (auto* zone = zones.begin(); zone != zones.end(); ++zone) - if (zone->getMasterChannel() == channel) - return zone; + return const_cast (static_cast (*this).getZoneByChannel (channel)); +} + +const MPEZone* MPEZoneLayout::getZoneByMasterChannel (int channel) const noexcept +{ + for (auto& zone : zones) + if (zone.getMasterChannel() == channel) + return &zone; return nullptr; } -MPEZone* MPEZoneLayout::getZoneByFirstNoteChannel (int channel) const noexcept +MPEZone* MPEZoneLayout::getZoneByMasterChannel (int channel) noexcept { - for (auto* zone = zones.begin(); zone != zones.end(); ++zone) - if (zone->getFirstNoteChannel() == channel) - return zone; + return const_cast (static_cast (*this).getZoneByMasterChannel (channel)); +} + +const MPEZone* MPEZoneLayout::getZoneByFirstNoteChannel (int channel) const noexcept +{ + for (auto& zone : zones) + if (zone.getFirstNoteChannel() == channel) + return &zone; return nullptr; } -MPEZone* MPEZoneLayout::getZoneByNoteChannel (int channel) const noexcept +MPEZone* MPEZoneLayout::getZoneByFirstNoteChannel (int channel) noexcept { - for (auto* zone = zones.begin(); zone != zones.end(); ++zone) - if (zone->isUsingChannelAsNoteChannel (channel)) - return zone; + return const_cast (static_cast (*this).getZoneByFirstNoteChannel (channel)); +} + +const MPEZone* MPEZoneLayout::getZoneByNoteChannel (int channel) const noexcept +{ + for (auto& zone : zones) + if (zone.isUsingChannelAsNoteChannel (channel)) + return &zone; return nullptr; } +MPEZone* MPEZoneLayout::getZoneByNoteChannel (int channel) noexcept +{ + return const_cast (static_cast (*this).getZoneByNoteChannel (channel)); +} + //============================================================================== void MPEZoneLayout::addListener (Listener* const listenerToAdd) noexcept { diff --git a/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h b/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h index c24accedd8..bbb24a6dba 100644 --- a/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h +++ b/modules/juce_audio_basics/mpe/juce_MPEZoneLayout.h @@ -101,27 +101,32 @@ public: is no such zone. Zones are sorted by insertion order (most recently added zone last). */ - MPEZone* getZoneByIndex (int index) const noexcept; + MPEZone* getZoneByIndex (int index) noexcept; + const MPEZone* getZoneByIndex (int index) const noexcept; /** Returns a pointer to the zone which uses the specified channel (1-16), or nullptr if there is no such zone. */ - MPEZone* getZoneByChannel (int midiChannel) const noexcept; + MPEZone* getZoneByChannel (int midiChannel) noexcept; + const MPEZone* getZoneByChannel (int midiChannel) const noexcept; /** Returns a pointer to the zone which has the specified channel (1-16) as its master channel, or nullptr if there is no such zone. */ - MPEZone* getZoneByMasterChannel (int midiChannel) const noexcept; + MPEZone* getZoneByMasterChannel (int midiChannel) noexcept; + const MPEZone* getZoneByMasterChannel (int midiChannel) const noexcept; /** Returns a pointer to the zone which has the specified channel (1-16) as its first note channel, or nullptr if there is no such zone. */ - MPEZone* getZoneByFirstNoteChannel (int midiChannel) const noexcept; + MPEZone* getZoneByFirstNoteChannel (int midiChannel) noexcept; + const MPEZone* getZoneByFirstNoteChannel (int midiChannel) const noexcept; /** Returns a pointer to the zone which has the specified channel (1-16) as one of its note channels, or nullptr if there is no such zone. */ - MPEZone* getZoneByNoteChannel (int midiChannel) const noexcept; + MPEZone* getZoneByNoteChannel (int midiChannel) noexcept; + const MPEZone* getZoneByNoteChannel (int midiChannel) const noexcept; //============================================================================== /** Listener class. Derive from this class to allow your class to be diff --git a/modules/juce_audio_formats/format/juce_AudioFormatManager.h b/modules/juce_audio_formats/format/juce_AudioFormatManager.h index 15a97a1e3f..9abed6bd59 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatManager.h +++ b/modules/juce_audio_formats/format/juce_AudioFormatManager.h @@ -78,10 +78,12 @@ public: AudioFormat* getKnownFormat (int index) const; /** Iterator access to the list of known formats. */ - AudioFormat** begin() const noexcept { return knownFormats.begin(); } + AudioFormat** begin() noexcept { return knownFormats.begin(); } + AudioFormat*const* begin() const noexcept { return knownFormats.begin(); } /** Iterator access to the list of known formats. */ - AudioFormat** end() const noexcept { return knownFormats.end(); } + AudioFormat** end() noexcept { return knownFormats.end(); } + AudioFormat*const* end() const noexcept { return knownFormats.end(); } /** Looks for which of the known formats is listed as being for a given file extension. diff --git a/modules/juce_audio_processors/scanning/juce_KnownPluginList.h b/modules/juce_audio_processors/scanning/juce_KnownPluginList.h index 3bfa606b5f..0b938ad507 100644 --- a/modules/juce_audio_processors/scanning/juce_KnownPluginList.h +++ b/modules/juce_audio_processors/scanning/juce_KnownPluginList.h @@ -61,9 +61,12 @@ public: PluginDescription* getType (int index) const noexcept { return types [index]; } /** Type iteration. */ - PluginDescription** begin() const noexcept { return types.begin(); } + PluginDescription** begin() noexcept { return types.begin(); } + PluginDescription*const* begin() const noexcept { return types.begin(); } + /** Type iteration. */ - PluginDescription** end() const noexcept { return types.end(); } + PluginDescription** end() noexcept { return types.end(); } + PluginDescription*const* end() const noexcept { return types.end(); } /** Looks for a type in the list which comes from this file. */ PluginDescription* getTypeForFile (const String& fileOrIdentifier) const; diff --git a/modules/juce_blocks_basics/blocks/juce_TouchList.h b/modules/juce_blocks_basics/blocks/juce_TouchList.h index 81a4a4680d..d532492d88 100644 --- a/modules/juce_blocks_basics/blocks/juce_TouchList.h +++ b/modules/juce_blocks_basics/blocks/juce_TouchList.h @@ -106,7 +106,7 @@ public: /** If a touch is in the list, returns a pointer to the TouchEntry. Otherwise, returns nullptr. */ - TouchEntry* find (const TouchSurface::Touch& touch) const noexcept + const TouchEntry* find (const TouchSurface::Touch& touch) const noexcept { for (auto& t : touches) if (matches (t.touch, touch)) @@ -115,17 +115,24 @@ public: return nullptr; } - /** Allows iterator access to the list of touch entries. */ - TouchEntry* begin() const noexcept { return touches.begin(); } + TouchEntry* find (const TouchSurface::Touch& touch) noexcept + { + return const_cast (static_cast (*this).find (touch)); + } /** Allows iterator access to the list of touch entries. */ - TouchEntry* end() const noexcept { return touches.end(); } + TouchEntry* begin() noexcept { return touches.begin(); } + const TouchEntry* begin() const noexcept { return touches.begin(); } + + /** Allows iterator access to the list of touch entries. */ + TouchEntry* end() noexcept { return touches.end(); } + const TouchEntry* end() const noexcept { return touches.end(); } /** Retrieve a reference to particular item in the list of touch entires. */ - TouchEntry& operator[] (const int index) { return touches.getReference (index); } + TouchEntry& operator[] (const int index) { return touches.getReference (index); } /** Resets all contents, doest not generate any call-backs. */ - void clear() noexcept { touches.clear(); } + void clear() noexcept { touches.clear(); } private: //========================================================================== diff --git a/modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h b/modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h index 0ac0ac8dcc..3fdf85a243 100644 --- a/modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h +++ b/modules/juce_blocks_basics/littlefoot/juce_LittleFootCompiler.h @@ -405,7 +405,7 @@ private: f->block->simplify (*this); } - Function* findFunction (FunctionID functionID) const noexcept + const Function* findFunction (FunctionID functionID) const noexcept { for (auto f : functions) if (f->functionID == functionID) @@ -414,7 +414,7 @@ private: return nullptr; } - NativeFunction* findNativeFunction (FunctionID functionID) const noexcept + const NativeFunction* findNativeFunction (FunctionID functionID) const noexcept { for (auto& f : nativeFunctions) if (f.functionID == functionID) diff --git a/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp b/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp index e27d786c0e..27416d5e4a 100644 --- a/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp +++ b/modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp @@ -443,7 +443,7 @@ struct PhysicalTopologySource::Internal return -1; } - DeviceInfo* getDeviceInfoFromUID (Block::UID uid) const noexcept + const DeviceInfo* getDeviceInfoFromUID (Block::UID uid) const noexcept { for (auto& d : currentDeviceInfo) if (d.uid == uid) diff --git a/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp b/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp index 123e576be8..fe97d7a156 100644 --- a/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp +++ b/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp @@ -148,7 +148,7 @@ void GlyphArrangement::clear() glyphs.clear(); } -PositionedGlyph& GlyphArrangement::getGlyph (int index) const noexcept +PositionedGlyph& GlyphArrangement::getGlyph (int index) noexcept { return glyphs.getReference (index); } diff --git a/modules/juce_graphics/fonts/juce_GlyphArrangement.h b/modules/juce_graphics/fonts/juce_GlyphArrangement.h index 4d617895fc..d2f854c36b 100644 --- a/modules/juce_graphics/fonts/juce_GlyphArrangement.h +++ b/modules/juce_graphics/fonts/juce_GlyphArrangement.h @@ -146,7 +146,7 @@ public: careful not to pass an out-of-range index here, as it doesn't do any bounds-checking. */ - PositionedGlyph& getGlyph (int index) const noexcept; + PositionedGlyph& getGlyph (int index) noexcept; const PositionedGlyph* begin() const { return glyphs.begin(); } const PositionedGlyph* end() const { return glyphs.end(); } diff --git a/modules/juce_gui_basics/components/juce_Desktop.cpp b/modules/juce_gui_basics/components/juce_Desktop.cpp index 27fdd37763..ae89ed4be3 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.cpp +++ b/modules/juce_gui_basics/components/juce_Desktop.cpp @@ -179,13 +179,13 @@ int Desktop::getMouseWheelMoveCounter() const noexcept { return mouseWheelC void Desktop::incrementMouseClickCounter() noexcept { ++mouseClickCounter; } void Desktop::incrementMouseWheelCounter() noexcept { ++mouseWheelCounter; } -const Array& Desktop::getMouseSources() const noexcept { return mouseSources->sourceArray; } -int Desktop::getNumMouseSources() const noexcept { return mouseSources->sources.size(); } -int Desktop::getNumDraggingMouseSources() const noexcept { return mouseSources->getNumDraggingMouseSources(); } -MouseInputSource* Desktop::getMouseSource (int index) const noexcept { return mouseSources->getMouseSource (index); } -MouseInputSource* Desktop::getDraggingMouseSource (int index) const noexcept { return mouseSources->getDraggingMouseSource (index); } -MouseInputSource Desktop::getMainMouseSource() const noexcept { return MouseInputSource (mouseSources->sources.getUnchecked(0)); } -void Desktop::beginDragAutoRepeat (int interval) { mouseSources->beginDragAutoRepeat (interval); } +const Array& Desktop::getMouseSources() const noexcept { return mouseSources->sourceArray; } +int Desktop::getNumMouseSources() const noexcept { return mouseSources->sources.size(); } +int Desktop::getNumDraggingMouseSources() const noexcept { return mouseSources->getNumDraggingMouseSources(); } +MouseInputSource* Desktop::getMouseSource (int index) const noexcept { return mouseSources->getMouseSource (index); } +MouseInputSource* Desktop::getDraggingMouseSource (int index) const noexcept { return mouseSources->getDraggingMouseSource (index); } +MouseInputSource Desktop::getMainMouseSource() const noexcept { return MouseInputSource (mouseSources->sources.getUnchecked(0)); } +void Desktop::beginDragAutoRepeat (int interval) { mouseSources->beginDragAutoRepeat (interval); } //============================================================================== void Desktop::addFocusChangeListener (FocusChangeListener* const listener) { focusListeners.add (listener); } diff --git a/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp b/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp index f5dad1d1b1..73a29cf2b0 100644 --- a/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp +++ b/modules/juce_gui_basics/layout/juce_ConcertinaPanel.cpp @@ -183,14 +183,14 @@ private: int getTotalSize (int start, const int end) const noexcept { int tot = 0; - while (start < end) tot += get(start++).size; + while (start < end) tot += get (start++).size; return tot; } int getMinimumSize (int start, const int end) const noexcept { int tot = 0; - while (start < end) tot += get(start++).minSize; + while (start < end) tot += get (start++).minSize; return tot; } @@ -199,7 +199,7 @@ private: int tot = 0; while (start < end) { - const int mx = get(start++).maxSize; + const int mx = get (start++).maxSize; if (mx > 0x100000) return mx; @@ -429,9 +429,9 @@ void ConcertinaPanel::applyLayout (const PanelSizes& sizes, const bool animate) for (int i = 0; i < holders.size(); ++i) { - PanelHolder& p = *holders.getUnchecked(i); + PanelHolder& p = *holders.getUnchecked (i); - const int h = sizes.get(i).size; + const int h = sizes.get (i).size; const Rectangle pos (0, y, w, h); if (animate) diff --git a/modules/juce_gui_basics/layout/juce_FlexBox.cpp b/modules/juce_gui_basics/layout/juce_FlexBox.cpp index e111300268..62f4f95340 100644 --- a/modules/juce_gui_basics/layout/juce_FlexBox.cpp +++ b/modules/juce_gui_basics/layout/juce_FlexBox.cpp @@ -31,10 +31,10 @@ struct FlexBoxLayoutCalculation { using Coord = double; - FlexBoxLayoutCalculation (const FlexBox& fb, Coord w, Coord h) + FlexBoxLayoutCalculation (FlexBox& fb, Coord w, Coord h) : owner (fb), parentWidth (w), parentHeight (h), numItems (owner.items.size()), isRowDirection (fb.flexDirection == FlexBox::Direction::row - || fb.flexDirection == FlexBox::Direction::rowReverse), + || fb.flexDirection == FlexBox::Direction::rowReverse), containerLineLength (isRowDirection ? parentWidth : parentHeight) { lineItems.calloc (numItems * numItems); @@ -84,7 +84,7 @@ struct FlexBoxLayoutCalculation Coord crossSize, lineY, totalLength; }; - const FlexBox& owner; + FlexBox& owner; const Coord parentWidth, parentHeight; const int numItems; const bool isRowDirection; diff --git a/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h b/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h index 19211b0157..5d0e0b2e1b 100644 --- a/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h +++ b/modules/juce_gui_basics/mouse/juce_SelectedItemSet.h @@ -78,12 +78,12 @@ public: if (! other.isSelected (selectedItems.getReference (i))) itemDeselected (selectedItems.removeAndReturn (i)); - for (SelectableItemType* i = other.selectedItems.begin(), *e = other.selectedItems.end(); i != e; ++i) + for (auto& i : selectedItems) { - if (! isSelected (*i)) + if (! isSelected (i)) { - selectedItems.add (*i); - itemSelected (*i); + selectedItems.add (i); + itemSelected (i); } } } diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 71a3cca0e3..ad8c855c47 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -1121,7 +1121,7 @@ public: isVertical() ? pixelPos : (owner.getHeight() / 2.0f))); } - ms.setScreenPosition (mousePos); + const_cast (ms).setScreenPosition (mousePos); } } } diff --git a/modules/juce_osc/osc/juce_OSCBundle.cpp b/modules/juce_osc/osc/juce_OSCBundle.cpp index e2041834d6..c5c47192e5 100644 --- a/modules/juce_osc/osc/juce_OSCBundle.cpp +++ b/modules/juce_osc/osc/juce_OSCBundle.cpp @@ -195,15 +195,15 @@ private: expect (! bundle[1].isBundle()); int numElementsCounted = 0; - for (OSCBundle::Element* element = bundle.begin(); element != bundle.end(); ++element) + for (auto& element : bundle) { - expect (element->isMessage()); - expect (! element->isBundle()); + expect (element.isMessage()); + expect (! element.isBundle()); ++numElementsCounted; } expectEquals (numElementsCounted, 2); - OSCBundle::Element* e = bundle.begin(); + auto* e = bundle.begin(); expect (e[0].getMessage().size() == 1); expect (e[0].getMessage().begin()->getInt32() == testInt); expect (e[1].getMessage().size() == 2); diff --git a/modules/juce_osc/osc/juce_OSCBundle.h b/modules/juce_osc/osc/juce_OSCBundle.h index b3b0d4861e..e9c302ac09 100644 --- a/modules/juce_osc/osc/juce_OSCBundle.h +++ b/modules/juce_osc/osc/juce_OSCBundle.h @@ -111,7 +111,12 @@ public: This method does not check the range and results in undefined behaviour in case i < 0 or i >= size(). */ - OSCBundle::Element& operator[] (const int i) const noexcept + OSCBundle::Element& operator[] (const int i) noexcept + { + return elements.getReference (i); + } + + const OSCBundle::Element& operator[] (const int i) const noexcept { return elements.getReference (i); } diff --git a/modules/juce_osc/osc/juce_OSCMessage.cpp b/modules/juce_osc/osc/juce_OSCMessage.cpp index 6bb21cef21..994d954bd6 100644 --- a/modules/juce_osc/osc/juce_OSCMessage.cpp +++ b/modules/juce_osc/osc/juce_OSCMessage.cpp @@ -53,7 +53,12 @@ bool OSCMessage::isEmpty() const noexcept return arguments.isEmpty(); } -OSCArgument& OSCMessage::operator[] (const int i) const noexcept +OSCArgument& OSCMessage::operator[] (const int i) noexcept +{ + return arguments.getReference (i); +} + +const OSCArgument& OSCMessage::operator[] (const int i) const noexcept { return arguments.getReference (i); } diff --git a/modules/juce_osc/osc/juce_OSCMessage.h b/modules/juce_osc/osc/juce_OSCMessage.h index 1d2f7fcf7e..117d3bcb95 100644 --- a/modules/juce_osc/osc/juce_OSCMessage.h +++ b/modules/juce_osc/osc/juce_OSCMessage.h @@ -93,7 +93,8 @@ public: This method does not check the range and results in undefined behaviour in case i < 0 or i >= size(). */ - OSCArgument& operator[] (const int i) const noexcept; + OSCArgument& operator[] (const int i) noexcept; + const OSCArgument& operator[] (const int i) const noexcept; /** Returns a pointer to the first OSCArgument in the OSCMessage object. This method is provided for compatibility with standard C++ iteration mechanisms. @@ -108,7 +109,6 @@ public: /** Removes all arguments from the OSCMessage. */ void clear(); - //============================================================================== /** Creates a new OSCArgument of type int32 with a given value and adds it to the OSCMessage object.