@@ -40,44 +40,42 @@ struct Annotated(T) {
4040 static if (_alloc_)
4141 {
4242 // /
43- private T* _value_ ;
43+ private T* _value ;
4444 // /
45- ref inout (T) _value () inout @property
45+ ref inout (T) value () inout @property
4646 {
47- return * _value_ ;
47+ return * _value ;
4848 }
4949
5050 // /
51- ref T _value (T value) @property
51+ ref T value (T value) @property
5252 {
53- if (_value_ is null )
53+ if (_value is null )
5454 {
55- _value_ = new T;
55+ _value = new T;
5656 import core.lifetime : move;
57- * _value_ = move(value);
57+ * _value = move(value);
5858 }
59- return * _value_ ;
59+ return * _value ;
6060 }
6161
6262 // /
6363 bool opEquals (const Annotated rhs) const
6464 {
65- return annotations == rhs.annotations && _value == rhs._value ;
65+ return annotations == rhs.annotations && value == rhs.value ;
6666 }
6767 }
6868 else
6969 {
7070 // /
71- T _value ;
71+ T value ;
7272 }
7373
74- // /
75- alias _value this ;
7674
7775 /+ +
7876 Params:
7977 annotations = non-empty array of annotations
80- value = actual value
78+ args = arguments to construct value with
8179 +/
8280 this (Args... )(string [] annotations, Args args) @safe pure {
8381 if (annotations.length == 0 )
@@ -90,15 +88,15 @@ struct Annotated(T) {
9088 import core.lifetime : forward;
9189 this .annotations = annotations;
9290 static if (_alloc_)
93- this ._value_ = new T(forward! args);
91+ this ._value = new T(forward! args);
9492 else
9593 static if (__traits(compiles, value = args))
96- this ._value = args;
94+ this .value = args;
9795 else
9896 static if (is (T == class ))
99- this ._value = new T(forward! args);
97+ this .value = new T(forward! args);
10098 else
101- this ._value = T(forward! args);
99+ this .value = T(forward! args);
102100 }
103101}
104102
@@ -109,12 +107,12 @@ unittest
109107 static struct S {double x;}
110108 auto as = Annotated! S(annotations, 5 );
111109 assert (as.annotations == annotations);
112- assert (as.x == 5 );
110+ assert (as.value. x == 5 );
113111
114112 static struct C {double x;}
115113 auto ac = Annotated! S(annotations, 5 );
116114 assert (ac.annotations == annotations);
117- assert (ac.x == 5 );
115+ assert (ac.value. x == 5 );
118116}
119117
120118// /
@@ -125,10 +123,10 @@ unittest
125123 static struct S {double x;}
126124 auto as = Annotated! (Variant ! S)(annotations, 5 );
127125 assert (as.annotations == annotations);
128- assert (as.x == 5 );
126+ assert (as.value. x == 5 );
129127
130128 static struct C {double x;}
131129 auto ac = Annotated! (Variant ! S)(annotations, 5 );
132130 assert (ac.annotations == annotations);
133- assert (ac.x == 5 );
131+ assert (ac.value. x == 5 );
134132}
0 commit comments