On Wed, 25 Feb 2009 06:31:37 +1300, Justin <[email protected]> wrote:
I can probably figure out the bulk of the problem if someone can direct
me to the correct way of mixing in a bunch of functions and having them
overload each other properly. I'm using D 1.39 and the documentation
indicated that I needed to use the MixinDeclaration and aliases, so this
is what I have:
mixin tSetValue!(bool) tm_bool;
mixin tSetValue!(byte) tm_byte;
mixin tSetValue!(ubyte) tm_ubyte;
mixin tSetValue!(int) tm_int;
mixin tSetValue!(uint) tm_uint;
mixin tSetValue!(long) tm_long;
mixin tSetValue!(ulong) tm_ulong;
mixin tSetValue!(float) tm_float;
mixin tSetValue!(double) tm_double;
mixin tSetValue!(real) tm_real;
mixin tSetValue!(char) tm_char;
mixin tSetValue!(Object) tm_Object;
alias tm_bool.SetValue SetValue;
alias tm_byte.SetValue SetValue;
alias tm_ubyte.SetValue SetValue;
alias tm_int.SetValue SetValue;
alias tm_uint.SetValue SetValue;
alias tm_long.SetValue SetValue;
alias tm_ulong.SetValue SetValue;
alias tm_float.SetValue SetValue;
alias tm_double.SetValue SetValue;
alias tm_real.SetValue SetValue;
alias tm_char.SetValue SetValue;
alias tm_Object.SetValue SetValue;
But it seems that only the first use is recognized and the compiler
tries to match all uses of the function to that first signature (bool).
You are probably using alias and/or mixin incorrectly. It would be easier
with full source but as a guess are you trying to do something like this:
module main;
class TypeThing(T)
{
T data;
this()
{
//
}
void SetValue(T data)
{
this.data = data;
}
}
class boolThing : TypeThing!(bool)
{
this()
{
//
}
}
void Register(char[] t)()
{
mixin("class "~t~"Thing : TypeThing!("~t~")
{
this()
{
//
}
}");
}
void main()
{
Register!("bool");
Register!("char");
}