Advertisement

Registering a C++ template function

Started by July 18, 2013 04:17 PM
0 comments, last by WitchLord 11 years, 4 months ago

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/

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

This topic is closed to new replies.

Advertisement