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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top