friend function could be an option

But I agree with Speedo, makes sense to have it as a member function as it operates exclusively on the class, unless there is a special reason.