Template shenannigans with multiple datatypes

vit vit at vit.vit
Fri May 13 07:05:36 UTC 2022


On Friday, 13 May 2022 at 06:43:39 UTC, Chris Katko wrote:
> I have an intrinsicGraph(T) class that is given a pointer to a 
> T dataSource and automatically polls that variable every frame 
> to add it to the graph, whether it's a float, double, integer, 
> and maybe bool.
>
> [...]

I dont understand first qestion but second question has a 
solution:

```d
intrinsic_graph!T make_graph(T, Args...)(auto ref T val, auto ref 
Args args){
	return new intrinsic_graph!T(val, args);
}


instrinsicGraph!float testGraph;
instrinsicGraph!ulong testGraph2;
// later
testGraph = make_graph(units[0].x, 100, 300, COLOR(1,0,0,1));
testGraph2 = make_graph(g.stats.fps, 100, 500, COLOR(1,0,0,1));


```


More information about the Digitalmars-d-learn mailing list