Std::list

To be extra correct, I think here you meant: “you should use a reference to the (pointed) object

Hey Jules.
Sorry for not answering. By the time I finished it was already late at night. I have attached a screenshot. There I used your code. Most likely, I did not succeed, because I still know C ++ too poorly and I have little experience. I study it for only half a year, because. I have been doing music for 50 years. Many thanks to everyone for the help. I created a wonderful audio player with audio and midi playback, with a playlist. It happened because there are a lot of sympathetic people on the forum who are ready to help. I will keep learning C++ and amazing Juce!

1 Like

I still have a long way to go to learn.

Yeah, yeah, OK… you knew what I meant though :slight_smile:

Not to make your life more complicated, but why is it that you’re using std::list in the first place? Iterating over a list is slow, and std::vector is often a better choice, especially for things like storing Components. The main case where using lists makes sense is when you frequently need to insert and remove elements from the middle of the list (which you don’t seem to be doing here).

I sure did!
I just wanted to point it out for the sake of future readers, which might not be so proficent in C++ to get it right

2 Likes

Even if you would insert and remove from the middle very often, the cache would make sure that std::vector is still faster than std::list.
The list might have an advantage when the objects moved around are huge. But here we have std::unique_ptrs, which are a few bytes only.

1 Like