On Wed, 02 Jun 2010 23:12:38 +0200, Adam Ruppe <destructiona...@gmail.com> wrote:

On 6/2/10, Simen kjaeraas <simen.kja...@gmail.com> wrote:
*snip*

I haven't tried your code, but it looks similar to my own code, which
had this problem:

alias Typedef!Int Handle;
alias Typedef!Int OtherHandle;

void foo(Handle h) { }

OtherHandle b;

foo(b); // compiles, but shouldn't. Problem is that Handle and
OtherHandle are both alias of the same underlying thing, so the
compiler considers them the same thing! With the old typedef, I'm
pretty sure it would (correctly IMO) complain here.

My code sidesteps that by including instantiation line and file,
making each instantiation unique (as long as you don't do
multiple typedefs on one line).

It is possible to sidestep this issue with a mixin template:

mixin template typedef( string name, T ) {
  mixin(q{
    struct } ~ name ~ q{ {
      //stuff
    }
  });
}

But 'mixin Typedef!("myInt", int);' does not sit well with me.

--
Simen

Reply via email to