You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/user-guide/03-convenience-features.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -149,7 +149,7 @@ int rs = foo.staticMethod(a,b);
149
149
150
150
### Mutability of member function
151
151
152
-
For GPU performance considerations, the `this` argument in a member function is immutable by default. If you modify the content in `this`argument, the modification will be discarded after the call and does not affect the input object. If you intend to define a member function that mutates the object, use `[mutating]` attribute on the member function as shown in the following example.
152
+
For GPU performance considerations, the `this` argument in a member function is immutable by default. Attempting to modify `this` will result in a compile error. If you intend to define a member function that mutates the object, use `[mutating]` attribute on the member function as shown in the following example.
153
153
154
154
```hlsl
155
155
struct Foo
@@ -159,14 +159,14 @@ struct Foo
159
159
[mutating]
160
160
void setCount(int x) { count = x; }
161
161
162
-
void setCount2(int x) { count = x; }
162
+
// This would fail to compile.
163
+
// void setCount2(int x) { count = x; }
163
164
}
164
165
165
166
void test()
166
167
{
167
168
Foo f;
168
-
f.setCount(1); // f.count is 1 after the call.
169
-
f.setCount2(2); // f.count is still 1 after the call.
0 commit comments