Sign in to follow this  
Bryan Harris

Implicit cast from built-in type to custom type

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,

Share this post

Link to post
Share on other sites
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this