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: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!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 }
Re: Template-style polymorphism in table structure
data pulverizer via Digitalmars-d-learn Sun, 04 Sep 2016 23:51:18 -0700
On Sunday, 4 September 2016 at 14:49:30 UTC, Lodovico Giaretta
wrote:
- Template-style polymorphism in t... data pulverizer via Digitalmars-d-learn
- Re: Template-style polymorp... Lodovico Giaretta via Digitalmars-d-learn
- Re: Template-style poly... data pulverizer via Digitalmars-d-learn
- Re: Template-style polymorp... ZombineDev via Digitalmars-d-learn
- Re: Template-style polymorp... data pulverizer via Digitalmars-d-learn
- Re: Template-style poly... data pulverizer via Digitalmars-d-learn
- Re: Template-style ... data pulverizer via Digitalmars-d-learn
- Re: Template-st... Lodovico Giaretta via Digitalmars-d-learn
- Re: Templa... data pulverizer via Digitalmars-d-learn
- Re: Templa... data pulverizer via Digitalmars-d-learn