Sign in to follow this  
Starfox

Registering a C++ template function

Recommended Posts

Starfox    504

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.

Share this post


Link to post
Share on other sites
WitchLord    4677

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.

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