Get difficulties with variadics

Flamaros flamaros.xavier at gmail.com
Fri May 10 14:11:56 PDT 2013


I am using a variadic function for a resource manager to be able 
to load resources with custom parameters.

My problem is I don't get the second parameter correctly, i am 
expecting to retrieve a dynamic array.

[CODE]
class ResourceManager
     T    getResource(T : IResource)(string filePath, ...)
     {
         T	instance;

	...
		
	instance = new T;
	instance.load(filePath, _arguments);

	...
		
	return instance;
     }
}
	
class VBO(T) : IResource
{
     mixin ResourceBase;

public:
     void	load(...)
     {
	string	filePath = va_arg!string(_argptr);
		
	auto size = _arguments[0].tsize();
	_argptr += ((size + size_t.sizeof - 1) & ~(size_t.sizeof - 1));
	mArray = va_arg!(T[])(_argptr);

	mArray = cast(T[])_arguments[1];

	...
     }
}

// Somewhere else I try to retrieve the resource
mIndexes = 
resourceManager.getResource!(VBO!GLushort)("dquick.renderer_2d.opengl.rectangle.indexes", 
[0, 1, 2, 1, 3, 2]);	// We use the module name as basePath and 
the variable name as filename

[/CODE]

In the load(...) method I am getting filePath without issue, but 
for next parameters I am little confused on how to do.


More information about the Digitalmars-d-learn mailing list