Why can't the as operator perform user-defined conversions?

  • Thread starter Thread starter Guest
  • Start date Start date
Why can't the as operator perform user-defined conversions?

My guess it has to do with the resolution and chaining rules for implicit
and explicit conversion invocations.

The rules are actually different when you invoke a conversion explicitly
with a cast vs invoking it implicitly. Note that this is how the conversion
operator is *invoked*, not how it is *defined*. Explicit conversion operators
must be invoked explicitly while implicit operators can be used either way.

There would have to be more rules or syntax to distinguish the cases when
using the "as" operator. Perhaps they thought it was just more trouble than
it was worth?
 
Back
Top