PERF: use hidden friend idiom pattern when overloading operator== (code review)

1 job for compare-metadata in 3 minutes and 40 seconds (queued for 3 seconds)
Status Job ID Name Coverage
  Precheck
canceled #33331
fast-build

00:03:40