refactoring define operator~ as member function