Allow comparison with enum classes

This addresses the issue of using enums in a case statement and also
makes the API more predictable.