Synax for variadic template
    Alex via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Fri Sep  1 02:38:59 PDT 2017
    
    
  
Hi all!
Say, I have
struct A(T...)
{
	T arr;
}
struct B(T...)
{
	T[] arr;
}
void main()
{
	A!(int[], double[]) a;
	a.arr[0] ~= 5;
	a.arr[0] ~= 6;
	static assert(!__traits(compiles, a.arr[0] ~= 3.5));
	a.arr[1] ~= 19.8;
	
	assert(a.arr[0] == [5,6]);
	assert(a.arr[1] == [19.8]);
	assert(a.arr[1].length == 1);
	assert(a.arr[0].length == 2);
	
	B!(int, double) b;
	//b.arr[0] ~= 5;
}
While struct A behaves like expected, how to get by with B?
What I want is just to abstract the array property out of 
template arguments...
Thanks in advance :)
    
    
More information about the Digitalmars-d-learn
mailing list