Re: isMutable doesn't work with enum ?

2013-06-02 Thread Jonathan M Davis
On Monday, June 03, 2013 00:36:46 Temtaime wrote: > I'm writing serializer and it iterates all members of struct. > It compares fields marked as "enum" when reading from file to > check BOM, for example. > > I'm using enum now because const members are deprecated in 2.063. The equivalent to what

Re: isMutable doesn't work with enum ?

2013-06-02 Thread Jonathan M Davis
On Monday, June 03, 2013 00:34:49 Temtaime wrote: > It's intresting. > So the only way to pass "a" to overloaded function like that ? > > void foo(T)(ref T) { writeln("true"); } > void foo(T)(auto ref in T) { writeln("false"); } > > enum int a = 10; > foo(a); // false > > int b = 1; > foo(b); //

Re: isMutable doesn't work with enum ?

2013-06-02 Thread Temtaime
I'm writing serializer and it iterates all members of struct. It compares fields marked as "enum" when reading from file to check BOM, for example. I'm using enum now because const members are deprecated in 2.063.

Re: isMutable doesn't work with enum ?

2013-06-02 Thread Temtaime
It's intresting. So the only way to pass "a" to overloaded function like that ? void foo(T)(ref T) { writeln("true"); } void foo(T)(auto ref in T) { writeln("false"); } enum int a = 10; foo(a); // false int b = 1; foo(b); // true

Re: isMutable doesn't work with enum ?

2013-06-02 Thread bearophile
Temtaime: enum int a = 5; writeln(isMutable!(typeof(a))); Writes true. Why? If you run this: enum int a = 5; pragma(msg, typeof(a)); void main() {} It prints "int". An int is mutable. How i can figure out if variable is "enum" constant ? Why do you need to know that?

Re: isMutable doesn't work with enum ?

2013-06-02 Thread Jonathan M Davis
On Monday, June 03, 2013 00:14:34 Temtaime wrote: > Hi! > > enum int a = 5; > writeln(isMutable!(typeof(a))); > > Writes true. Why? How i can figure out if variable is "enum" > constant ? > Thanks. > Regards. isMutable just checks whether the type const or immutable, and is true if i

isMutable doesn't work with enum ?

2013-06-02 Thread Temtaime
Hi! enum int a = 5; writeln(isMutable!(typeof(a))); Writes true. Why? How i can figure out if variable is "enum" constant ? Thanks. Regards.