Hello all,

Is there a way to construct a tuple of the types that need to be passed to a struct or class's constructor?

I tried using ParameterTypeTuple either on the class or its constructor:

    ParameterTypeTuple!A

or

    ParameterTypeTuple!(A.this)

... but neither works: the former generates an error,

Error: template instance ParameterTypeTuple!(A) ParameterTypeTuple!(A) does not match template declaration ParameterTypeTuple(func...) if (func.length == 1 && isCallable!(func))

while the latter generates,

    Error: identifier expected following '.', not 'this'

A (broken) bit of sample code is attached which illustrates what I'm trying to achieve. Can anyone advise?

Thanks & best wishes,

     -- Joe
import std.stdio, std.traits;

struct A
{
	private immutable int _a;
	private immutable double _b;

	this(int a, double b)
	{
		_a = a;
		_b = b;
	}

	auto alpha() @property
	{
		return _a;
	}

	auto beta() @property
	{
		return _b;
	}
}

struct B
{
	A one;
	A two;

	this(ParameterTypeTuple!A inputOne, ParameterTypeTuple!A inputTwo)
	{
		one = A(inputOne);
		two = A(inputTwo);
	}
}


void main()
{
	auto join = B(1, 3.2, 5, 6.9);
	writeln(join.one.alpha, "\t", join.one.beta);
	writeln(join.two.alpha, "\t", join.two.beta);
}

Reply via email to