Commit d76bb3a 1 parent da52d7a commit d76bb3a Copy full SHA for d76bb3a
File tree 1 file changed +13
-5
lines changed
1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -103,21 +103,21 @@ public:
103
103
}
104
104
105
105
static foreach (Field ; Fields)
106
- mixin (" Field.Type " ~ Field .name
107
- ~ " () @trusted { checkType!(Field.Type); return value.get!(Field.Type); }" );
106
+ mixin (" inout( Field.Type) " ~ Field .name
107
+ ~ " () @trusted inout { checkType!(Field.Type); return value.get!(Field.Type); }" );
108
108
109
- void checkType (T)()
109
+ void checkType (T)() const
110
110
{
111
111
if (! isType! T)
112
112
throw new Exception (" Attempted to access " ~ type ~ " field as " ~ T.stringof);
113
113
}
114
114
115
- bool isType (T)() @trusted
115
+ bool isType (T)() @trusted const
116
116
{
117
117
return value.type == typeid (T);
118
118
}
119
119
120
- string type ()
120
+ string type () const
121
121
{
122
122
if (! value.hasValue)
123
123
return null ;
@@ -221,4 +221,12 @@ unittest
221
221
" type" : Bson(" foo" ),
222
222
" value" : Bson([" x" : Bson(3 )])
223
223
]));
224
+
225
+ const x = var2;
226
+ assert (x.type == " foo" );
227
+ assert (x.isType! Foo );
228
+ assert (typeof (x).toBson(x) == Bson([
229
+ " type" : Bson(" foo" ),
230
+ " value" : Bson([" x" : Bson(3 )])
231
+ ]));
224
232
}
You can’t perform that action at this time.
0 commit comments