-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Un-deprecate removeMember overloads, return void #693
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
Un-deprecate removeMember overloads, return void #693
Conversation
Sometimes we just want to remove something we don't need anymore. Having to supply a return buffer for the removeMember function to return something we don't care about is a nuisance. There are removeMember overloads that don't need a return buffer but they are deprecated. This commit un-deprecates these overloads and modifies them to return nothing (void) instead of the object that was removed. Further discussion: #689 WARNING: Changes the return type of the formerly deprecated removeMember overloads from Value to void. May break existing client code.
src/lib_json/json_value.cpp
Outdated
} | ||
Value Value::removeMember(const JSONCPP_STRING& key) | ||
void Value::removeMember(const JSONCPP_STRING& key) | ||
{ | ||
return removeMember(key.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to drop the return
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning void from a void function works fine, it's just a matter of style. I left the return in to reduce the number of changed lines. Will submit a new commit but don't think that's the reason for the errors we got from the CI builds.
../src/lib_json/json_value.cpp:1205:26: error: return-statement with a value, in function returning 'void' [-fpermissive]
return nullSingleton();
^
../src/lib_json/json_value.cpp:1209:10: error: return-statement with a value, in function returning 'void' [-fpermissive]
return removed; // still null if removeMember() did nothing
^ |
Don't explicitly return a void value from a void function. Also, convert size_t to unsigned in the CZString ctor to avoid a compiler warning.
Sometimes we just want to remove something we don't need anymore. Having
to supply a return buffer for the removeMember function to return something
we don't care about is a nuisance. There are removeMember overloads that
don't need a return buffer but they are deprecated. This commit un-deprecates
these overloads and modifies them to return nothing (void) instead of the
object that was removed.
Further discussion: #689
WARNING: Changes the return type of the formerly deprecated removeMember
overloads from Value to void. May break existing client code.