Template recursion error on table struct

data pulverizer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Mar 26 03:24:40 PDT 2016


On Saturday, 26 March 2016 at 09:47:10 UTC, Ali Çehreli wrote:
> Please ignore my earlier response. :)
>
> On 03/25/2016 02:54 PM, data pulverizer wrote:
>
> > template ColumnTable(T...){
> [...]
> >          auto output = ColumnTable!(new_data)(new_data); //
> This is the
> > problem
>
> You want to slice the template arguments there. The following 
> removes the infinite recursion:
>
>         auto output = ColumnTable!(T[columnRange.begin .. 
> columnRange.end])(new_data);
>
> Ali

Thanks a lot! The subTable() method includes a loop to subset the 
rows which I forgot to include originally ...

auto subTable(Range rowRange, Range columnRange)(){
		auto new_data = data[columnRange.begin .. columnRange.end];
		foreach(i, col; new_data){
			new_data[i] = col[rowRange.begin .. rowRange.end];
		}
		auto output = ColumnTable!(T[columnRange.begin .. 
columnRange.end])(new_data);
		string[] new_names = names[columnRange.begin .. 
columnRange.end];
		output.setNames(new_names);
		return output;
	}



More information about the Digitalmars-d-learn mailing list