Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


- - - - -

Registering a C++ template function


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 Starfox   Members   -  Reputation: 504

Like
0Likes
Like

Posted 18 July 2013 - 10:17 AM

I have an object class that can host a variety of component subclasses. A helper function in object is components_of_type<T>, which returns an array of components of the specified type hosted by the object. Is there a way to register that functionality with a similar syntax in AngelScript? Right now I can do wrappers for specializations and expose them as "x_components()" or "y_components()" to wrap components_of_type<x> and components_of_type<y> separately, but a near-unified syntax between C++ and AngelScript code would be a plus.


Holy crap I started a blog - http://unobvious.typepad.com/

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3451

Like
0Likes
Like

Posted 18 July 2013 - 02:26 PM

It's currently not possible to register functions with the syntax 'components_of_type<T>' in AngelScript.

 

In C++ the template function is instanciated at compile time for each type used by the code. But for AngelScript to have the same syntax for a registered function you would have to somehow have a unified implementation that is able to work with all types and dynamically deciding at runtime what to do for each type.


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