Minor breaking change: Array::remove() return type

Just an FYI about the fact that we’ve just changed Array::remove() so that it now returns void rather than a copy of the object at that position.

If this causes problems in your code, it’s trivial to update: simply switch to using the new removeAndReturn() method instead, which has the same behaviour as the old version.

The reason we decided to do this is that the existing version requires the templated type to have both a default constructor and a copy constructor. That means that things like std::unique_ptr and other reasonable classes don’t work in an Array if you call remove(). So this small change opens up the range of types you can put in an array.

Why did we change the name of the existing method rather than adding a new method that returns void? Well, this way is nicer to read and less confusing. It’s also consistent with the OwnedArray class, which already has a pair of remove/removeAndReturn methods that work the same way.

I think it would be a good idea to collect all these topics regarding breaking changes into a “Breaking changes” category on their own, for easier reference

1 Like