Template help - MultiAccess

Era Scarecrow rtcvb32 at yahoo.com
Tue Jan 8 11:58:17 PST 2013


  I'm making a template to handle multiple accesses to the same 
name. In making my compression algorithm (and BitArray) I realize 
how much code is going into just forward referencing to things 
based on certain states.

  I have the following head template (there's about 5 total with 
how I see it):


   template multiAccess(Type, string name, string attributes,
           choice, bool read, bool write, T ...) {
     static assert(T.length % 2 == 0,
           "Must be in pairs, AccessName & matching Value");
     //eponymous enum
     enum multiAccess =
           multiAccessFunctions!(Type, name, attributes, choice, 
read, write, T);
   }


I'm calling it with:
   int choice;
   int a = 100;
   int b = 200;
   int c = 300;

   writeln(multiAccess!(int, "test", "@safe nothrow pure", choice, 
true, true,
     a, 0,
     b, 1,
     c, 2));

  And I'm getting the error of:

Error: template instance multiAccess!(int, "test", "@safe nothrow 
pure", choice, true, true, a, 0, b, 1, c, 2) multiAccess!(int, 
"test", "@safe nothrow pure", choice, true, true, a, 0, b, 1, c, 
2) does not match template declaration multiAccess(Type, string 
name, string attributes, choice, bool read, bool write, T...)

  Maybe something obvious but I'm not seeing it.


More information about the Digitalmars-d-learn mailing list