Convert to a template class in a function

  archicad, c++, templates

I’m lamenting about a simple function that converts objects from an array-like data structure into a linked list-like one, both being ArchiCAD’s own classes.

The question is that is it possible to do it for any kind of objects.

Code looks like this:

GS::Array<class T> *GetItemsFromNeig(API_Neig **p_neigs)
{
    UInt32 nSel =   BMGetHandleSize((GSHandle)p_neigs) / sizeof(API_Neig);
    GS::Array<T>*   resultArray = new GS::Array<T>;

    for (UInt32 ii = 0; ii < nSel; ++ii) {
        resultArray->Push((T) *p_neigs[ii]); //incomplete type is not allowed
    }

    return resultArray;
}

The error is not a surprise, the question is that is it possible to write a function like this.

Source: Windows Questions C++

LEAVE A COMMENT