FR: MessageListener::postMessage( std::unique_ptr<> )


#1

I’m all for making code require less and less documentation.

the current form of this function is this:

void MessageListener::postMessage	(	Message * 	message	)	const

it’s not obvious without reading the documentation that the MessageListener will take ownership of the passed-in message.

Since the framework isn’t using ScopedPointers and is using std::unique_ptr’s instead, I think the MessageListener class would benefit from this bit of self-documenting code, which shows that the MessageListener is taking ownership of the message you’re passing to it.

void MessageListener::postMessage( std::unique<ptr<Message> message ) const;

the only way to post a message would be to

std::unique_ptr<Message> myMessage = std::make_unique<Message>();
messageListener.postMessage( std::move( myMessage ) );

any comments?


#2

Yep, there are probably hundreds of places in the library where raw pointers need to be changed to unique_ptrs. We will change them because it’s safer and easier to understand, but given that it’ll annoy everyone who has to tweak their existing code we’re going to wait until a quiet moment to make that change!


#3

prolly juce6, eh?