Std::make_unique still necessary in current versions?

Hey there JUCErs!
I’m trying to expand upon and update some old JUCE code that used SkopedPointers and referencing against forum posts and tutorials, I’m confused as to whether we are still required to use std::unique_ptr for things like UI Elements.

e.g the old code defines SkopedPointer in header and constructs like:
addAndMakeVisible(newLabel = new Label("Label Name", "Label Text"));

which, by looking at forum should be now defined as std::unique_ptr and constructed like:
newLabel = std::make_unique<Label>("Label Name", "Label Text"); addAndMakeVisible(*newLabel);

But in the tutorial it seems Label can just be defined as Label and constructed without needing std::make_unique etc.

So has this become unnecessary in recent versions?

Using pointers (raw or ScopedPointer or unique_ptr) has never been required for a simple use case like that.

Pointers will become necessary for example if you want to have the components in a container object (array, vector or such), have a polymorphic component as a member or control more precisely when the component is created and destroyed.

1 Like

Ok thanks.