Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Implicit cast from built-in type to custom type


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Bryan Harris   Members   -  Reputation: 101

Like
0Likes
Like

Posted 20 November 2012 - 07:24 PM

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

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3197

Like
0Likes
Like

Posted 21 November 2012 - 01:44 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS