www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Can't create immutable type in template

reply "Nick Gurrola" <ngurrola17 gmail.com> writes:
import std.stdio;

void main()
{
	writeln(typeid(Test!int));
}

template Test(T...)
{
	alias immutable(T[0]) Test;
}


This prints "int" instead of "immutable(int)" like I would 
expect. Is this a bug, or is that what is supposed to happen?
Jul 15 2012
next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Monday, July 16, 2012 01:38:05 Nick Gurrola wrote:
 import std.stdio;
 
 void main()
 {
         writeln(typeid(Test!int));
 }
 
 template Test(T...)
 {
         alias immutable(T[0]) Test;
 }
It looks like a bug to me. - Jonathan M Davis
Jul 15 2012
prev sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
On 07/16/2012 01:38 AM, Nick Gurrola wrote:
 import std.stdio;

 void main()
 {
     writeln(typeid(Test!int));
 }

 template Test(T...)
 {
     alias immutable(T[0]) Test;
 }


 This prints "int" instead of "immutable(int)" like I would expect. Is
 this a bug, or is that what is supposed to happen?
This is a known issue. http://d.puremagic.com/issues/show_bug.cgi?id=6966 The bug report also contains a simple workaround.
Jul 16 2012