-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++ - const issue #190
Comments
Ah ok. The function itself doesn't do a mutation. But it still allows someone to do a mutation to a member. |
It seems now that I need two getter functions. Since if I have a readonly reference to A I can't call that GetB. I need to add this: Here's a sample, that's a bit different than the original above, that isn't allowed that shows what I mean:
|
Currently there's no other way. Unfortunately, these methods will be identical outside of C++ and C. You can of course remove one with Are you sure about your design of returning fields by reference? Why not provide modifier methods, e.g. public SetB!(string key, B value) { member[key] = value; } ? |
I have done modifier methods for most places that are public API. I mostly come across this with internal things where it was a shortcut to expose the member like that. So I guess I'll have to change the public ones that do that. And either live with two getters for the internal stuff or add methods. Thanks. |
If that's within your library code, why not define the fields as |
I was using internal at first. But then I noticed the friend issue with C++. So until you had fixed that I was trying to avoid using internal. So some of it is leftover from that. |
This results in:
'return': cannot convert from 'const B *' to 'B *'
Is this a C++ output issue? Or is this an issue with my fut code?
The text was updated successfully, but these errors were encountered: