On Sunday, 4 September 2016 at 14:49:30 UTC, Lodovico Giaretta wrote:
Your getCol(i) could become getCol!T(i) and return an instance of GenericVector!T directly, after checking that the required column has in fact that type:

GenericVector!T getCol!T(size_t i)
{
    if(typeid(cols[i]) == typeid(GenericVector!T))
        return cast(GenericVector!T)cols[i];
    else
        // assert(0) or throw exception
}
I just realized that typeid only gives the class and not the actual type, so the object will still need to be cast as you mentioned above, however your above function will not infer T, so the user will have to provide it. I wonder if there is a way to dispatch the right type by a dynamic cast or I fear that ZombineDev may be correct and the types will have to be limited, which I definitely want to avoid!


Reply via email to