Advertisement

Implicit cast from built-in type to custom type

Started by November 21, 2012 01:24 AM
0 comments, last by WitchLord 12 years ago
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
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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement