Fix Clang-trunk warnings about special members deprecated in C++20.#5829
Fix Clang-trunk warnings about special members deprecated in C++20.#5829aardappel merged 1 commit intogoogle:masterfrom Quuxplusone:assign-operators
Conversation
|
@vglavnyy: I don't see any obvious way to add you as an "Assignee" and/or "Reviewer", but, please take a look. |
| : fbb_(_fbb) { | ||
| start_ = fbb_.StartTable(); | ||
| } | ||
| TypeBuilder &operator=(const TypeBuilder &); |
There was a problem hiding this comment.
I agree, flatbuffers::FlatBufferBuilder &fbb_; blocks copy and move even if there was an idea to make &operator= private.
For example:
include/flatbuffers/reflection.h:365:8: error: definition of implicit copy
constructor for 'pointer_inside_vector<flatbuffers::Table, unsigned char>'
is deprecated because it has a user-declared copy assignment operator
[-Werror,-Wdeprecated-copy]
void operator=(const pointer_inside_vector &piv);
^
It's unclear why the old code wanted to declare a public `operator=`
without defining it; that just seems like a misunderstanding of the C++03 idiom
for deleting a member function. And anyway, we don't *want* to delete the
assignment operator; these are polymorphic types that do not follow value
semantics and nobody should ever be trying to copy them. So the simplest fix
is just to go back to the Rule of Zero: remove the declaration of `operator=`
and let the compiler do what it wanted to do originally anyway.
"The best code is no code."
Also, update the generated .h files.
Fixes #5649.
|
Updated (including your suggested fix to reflection.cpp). I think that it would probably be useful to investigate and eliminate all uses of |
|
LGTM |
This includes the fix for Clang 10: google/flatbuffers#5829
This includes the fix for Clang 10: google/flatbuffers#5829
…oogle#5829) For example: include/flatbuffers/reflection.h:365:8: error: definition of implicit copy constructor for 'pointer_inside_vector<flatbuffers::Table, unsigned char>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy] void operator=(const pointer_inside_vector &piv); ^ It's unclear why the old code wanted to declare a public `operator=` without defining it; that just seems like a misunderstanding of the C++03 idiom for deleting a member function. And anyway, we don't *want* to delete the assignment operator; these are polymorphic types that do not follow value semantics and nobody should ever be trying to copy them. So the simplest fix is just to go back to the Rule of Zero: remove the declaration of `operator=` and let the compiler do what it wanted to do originally anyway. "The best code is no code." Also, update the generated .h files. Fixes google#5649.
For example:
It's unclear why the old code wanted to declare a public
operator=without defining it; that just seems like a misunderstanding of the C++03 idiom
for deleting a member function. And anyway, we don't want to delete the
assignment operator; these are polymorphic types that do not follow value
semantics and nobody should ever be trying to copy them. So the simplest fix
is just to go back to the Rule of Zero: remove the declaration of
operator=and let the compiler do what it wanted to do originally anyway.
"The best code is no code."
Fixes #5649.