Last update Aug 16, 2004
int.sizeof // yields 4 float.nan // yields the floating point nan (Not A Number) value (float).nan // yields the floating point nan value (3).sizeof // yields 4 (because 3 is an int) 2.sizeof // syntax error, since "2." is a floating point number int.init // default initializer for int's
.init initializer (0) .sizeof size in bytes (equivalent to C's sizeof(type)) .alignof alignment size .max maximum value .min minimum value
.init initializer (NaN) .sizeof size in bytes (equivalent to C's sizeof(type)) .alignof alignment size .infinity infinity value .nan NaN value .dig number of decimal digits of precision .epsilon smallest increment .mant_dig number of bits in mantissa .max_10_exp maximum exponent as power of 10 .max_exp maximum exponent as power of 2 .min_10_exp minimum exponent as power of 10 .min_exp minimum exponent as power of 2 .max largest representable value that's not infinity .min smallest representable value that's not 0
int a; int b = 1; typedef int t = 2; t c; t d = cast(t)3; int.init // is 0 a.init // is 0 b.init // is 1 t.init // is 2 c.init // is 2 d.init // is 3 struct Foo { int a; int b = 7; } Foo.a.init // is 0 Foo.b.init // is 7
A simple property would be:
struct Foo { int data() { return m_data; } // read property int data(int value) { return m_data = value; } // write property private: int m_data; }To use it:
int test() { Foo f; f.data = 3; // same as f.data(3); return f.data + 3; // same as return f.data() + 3; }The absence of a read method means that the property is write-only. The absence of a write method means that the property is read-only. Multiple write methods can exist; the correct one is selected using the usual function overloading rules.
In all the other respects, these methods are like any other methods. They can be static, have different linkages, be overloaded with methods with multiple parameters, have their address taken, etc.
Note: Properties currently cannot be the lvalue of an op=, ++, or -- operator.