WARNING: Do not try to compile this code. Your computer may be unresponsive for a while. :)

On 03/25/2016 02:54 PM, data pulverizer wrote:
> I am attempting to create a table struct with generic column types using
> templates.

However, the template arguments are not types; rather, aliases.

> template ColumnTable(T...){
>      struct ColumnTable{
>      private:
>          typeof(T) data;
>          string[] names;
>          struct Range{
>              size_t begin;
>              size_t end;
>          }
>          // This function is the source of the issue
>      auto subTable(Range rowRange, Range columnRange)(){
>          auto new_data = data[columnRange.begin .. columnRange.end];
>          auto output = ColumnTable!(new_data)(new_data); // This is the
> problem

new_data is a local variable. So, this instantiation of ColumnTable is with that symbol.

> void main(){
>      string[] names = ["tariq", "sharma", "peter", "rakel"];
>      double[] salary = [44.5, 32.2, 40.1, 28.1];
>      int[] age = [24, 20, 22, 25, 19];
>      writeln(ColumnTable!(names, salary, age)(names, salary, age));
> }

Likewise, that instantiation of ColumnTable is with the symbols 'names', 'salary', and 'age'. Is that what you want? Or do you want to instantiate with their types? Can you explain some more what you are trying to do.

Ali

Reply via email to