template specialization

Larry Luther larry.luther at dolby.com
Tue Jun 8 14:25:43 PDT 2010


This code:

import std.stdio;


class A {

  void get (T:ubyte)(T[] buffer) {
    writefln( "get (T:ubyte)(T[] buffer)\n");
  }

  void get (T:byte)(T[] buffer) {
    writefln( "get (T:byte)(T[] buffer)\n");
  }

  void get (T)(T[] buffer) {
    writefln( "get (T)(T[] buffer)\n");
  }
}


void main () {
  A foo = new A;
  ubyte[100] ub;
  byte[100] bb;
  int[100] ib;

  foo.get( ub);
  foo.get( bb);
  foo.get( ib);
}

Generates:

  get (T:ubyte)(T[] buffer)

  get (T:ubyte)(T[] buffer)

  get (T)(T[] buffer)

Note:  If "get(T:byte)" preceeded "get(T:ubyte)" then "get(T:byte)" would be 
called in both cases.

Q: Is this the way it's supposed to be?

  Thanks, Larry





More information about the Digitalmars-d-learn mailing list