Type-safe compare