syntax for calling to with a getter as source argument

2014-07-14 Thread Klb via Digitalmars-d-learn
hello what is the right syntax for this: import std.stdio, std.conv; void main(string args[]) { ubyte[3] src = [0, 1, 2]; string trg = ""; @property ubyte[3] srcAsProp(){return src;} // Error: template std.conv.to cannot dedu

Re: syntax for calling to with a getter as source argument

2014-07-14 Thread Klb via Digitalmars-d-learn
On Tuesday, 15 July 2014 at 00:19:15 UTC, Ali Çehreli wrote: On 07/14/2014 05:10 PM, Ali Çehreli wrote: > On 07/14/2014 04:04 PM, H. S. Teoh via Digitalmars-d-learn wrote: > > > On Mon, Jul 14, 2014 at 09:12:30PM +0000, Klb via Digitalmars-d-learn > wrote: > >> hello

what is exactly stack stomp "-gx" new switch ?

2014-07-15 Thread Klb via Digitalmars-d-learn
...and any example where this switch will be usefull ?

Converting a POD struct to a class at compile-time ?

2014-07-16 Thread Klb via Digitalmars-d-learn
Hello, I'd like to know if it's possible, using CTFE, mixin etc to convert a POD struct to a class at compile time. I've reached the step where the string to mix-in is generated but I cant mix it: - import std.stdio; import std.trait

Re: Converting a POD struct to a class at compile-time ?

2014-07-16 Thread Klb via Digitalmars-d-learn
On Wednesday, 16 July 2014 at 18:09:10 UTC, Adam D. Ruppe wrote: On Wednesday, 16 July 2014 at 17:43:03 UTC, Klb wrote: auto names = __traits(allMembers, S); Error: static variable _names_field_0 cannot be read at compile time. The problem there is names is a regular runtime variable an

Re: Converting a POD struct to a class at compile-time ?

2014-07-16 Thread Klb via Digitalmars-d-learn
On Wednesday, 16 July 2014 at 18:09:10 UTC, Adam D. Ruppe wrote: On Wednesday, 16 July 2014 at 17:43:03 UTC, Klb wrote: auto names = __traits(allMembers, S); Error: static variable _names_field_0 cannot be read at compile time. The problem there is names is a regular runtime variable an

Trying to add automatic radix detection in std.conv.parse

2014-07-25 Thread klb via Digitalmars-d-learn
hello, I'd like to test if it's possible to add an automatic radix detection in std.conv, parse. I've added... if (s.length >= 2) { if (s[0..2] == "0x" || s[0..2] == "0X") { uint radix = 16; Source nbr = s[2..$];