safe_bool: Templatize over a class to make actually safe

Otherwise two unrelated classes using the safe bool idiom can be
meaninglessly compared, which is a disaster.