• Advertisement
Sign in to follow this  

Implicit cast from built-in type to custom type

This topic is 1889 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to register a behavior of a custom type I am implementing to be able to be implicitly cast to from built-in types.

How am I supposed to represent this with the RegisterObjectBehaviour function? The type for the obj parameter appears to be just custom types so you can't add functionality to built-in types. The type I am wanting to create is a value, plain old data type, so I don't want to use a class for the conversions.

Any help is greatly appreciated.

Thank you,
Bryan

Share this post


Link to post
Share on other sites
Advertisement
Implicit casts from built-in type to custom types are currently not supported. This is something that is still on my to-do list.


When it is supported though it will be done by registering a constructor/factory for the custom type that takes the built-in type. You can already register that constructor, but you'll have to call it explicitly to do the conversion.

Most situations where you'd use the implicit cast you can get working anyway by implementing overloaded functions to take the built-in type instead of the custom type. This usually gives better performance, even though it will require a bit more work to implement the overloads.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement