digitalmars.D.learn - Storing "auto" types in classes
- Rob Adelberg (15/15) Jul 02 2010 I'm sure this has come up before, but I want to store something like an
- Jonathan M Davis (6/26) Jul 02 2010 In this case, the type would be Appender!(packet[]). However, if you eve...
- BCS (5/36) Jul 02 2010 or you can get it at compile time:
I'm sure this has come up before, but I want to store something like an std.array appender in a class. All of the examples use auto for the type but you can't put that in a class definition, so what do you put? Example: class packet{...} class A { packet [] packetlist; appender!(packet) packappender; // wrong format this () { packetlist = new packet[0]; packappender = appender(&packetlist); } : } What's the format to store the appender in the class?
Jul 02 2010
On Friday, July 02, 2010 09:46:37 Rob Adelberg wrote:I'm sure this has come up before, but I want to store something like an std.array appender in a class. All of the examples use auto for the type but you can't put that in a class definition, so what do you put? Example: class packet{...} class A { packet [] packetlist; appender!(packet) packappender; // wrong format this () { packetlist = new packet[0]; packappender = appender(&packetlist); } } What's the format to store the appender in the class?In this case, the type would be Appender!(packet[]). However, if you ever want to know the exact type of something, one way to do it is something like this: writeln(typeid(appender(&packelist))); It will print out the type of the expression for you. - Jonathan M Davis
Jul 02 2010
Hello Jonathan,On Friday, July 02, 2010 09:46:37 Rob Adelberg wrote:or you can get it at compile time: pragma(msg, typeof(exp).stringof);I'm sure this has come up before, but I want to store something like an std.array appender in a class. All of the examples use auto for the type but you can't put that in a class definition, so what do you put? Example: class packet{...} class A { packet [] packetlist; appender!(packet) packappender; // wrong format this () { packetlist = new packet[0]; packappender = appender(&packetlist); } } What's the format to store the appender in the class?In this case, the type would be Appender!(packet[]). However, if you ever want to know the exact type of something, one way to do it is something like this: writeln(typeid(appender(&packelist))); It will print out the type of the expression for you.- Jonathan M Davis-- ... <IXOYE><
Jul 02 2010