-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Cleanup string classes #768
Conversation
This pull request introduces 8 alerts when merging de54549 into 7b85edc - view on LGTM.com new alerts:
|
LGTM is complaining that there are string class copy constructors but not copy assignment overloads. The copy assignment overload is unnecessary because the StringBase class already has a generic copy assignment overload for all strings. Since string classes already have a copy constructor from StringBase, ideally I'd remove the class copy constructor to get rid of this warning. Unfortunately, removing this class copy constructor triggers compiler warnings that the copy constructor isn't defined, despite the fact a perfectly valid StringBase constructor exists. I'm curious if there's some way I could hint at the compiler to use the StringBase constructor as the class copy constructor as well. |
@Joshua-Anderson you left a comment here is this work finalized or are you still working? |
@LeStarch This is ready to go... I just wanted to justify the LGTM warnings and see if anybody with more C++ experience has suggestions for better ways to solve this problem. |
@Joshua-Anderson the copy constructor for any class will either be explicit (user supplied) or implicit (compiler supplied) as the compiler must guarantee that the class is fully constructed after the constructor is called. For this reason it cannot use the base-class defined constructor. If an implicit constructor is used, the "default" base class constructor is used. |
de54549
to
aab9c1b
Compare
@LeStarch Following our discussion, I've added in copy assignment constructors as well as copy constructors. It seems likely that the compiler is properly calling the parent copy assignment constructor but it's unclear at best. Since C++ best practices recommend defining the copy assignment constructor when a copy constructor is defined, we may as well define the copy assignment constructors. |
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.
Discussed this with @timcanham. We decided it would be best to avoid virtual function use altogether in the constructors....so we should perform the copy with string_utils::string_copy
in the constructors.
Also we should clean up the base-class assignment operators as they return the wrong type. Based on the stl::string class a copy constructor should do:
const T& T::operator=(const B&)
aab9c1b
to
845628a
Compare
I replaced all the calls to copyBuff with a direct call to StringCopy. @LeStarch and I came to the consensus that |
27fc5a7
to
e1220ca
Compare
e1220ca
to
293ad0d
Compare
293ad0d
to
7ec49c1
Compare
7ec49c1
to
0453492
Compare
@check-spelling-bot ReportUnrecognized words, please review:
Previously acknowledged words that are now absentlxrTo accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands... in a clone of the git@github.com:Joshua-Anderson/fprime.git repository
|
Spelling fixed in another PR. |
Change Description
Cleanup F' string classes
Rationale
Future Work
I wan't able to cleanup the LogStringArg and TlmString classes yet - they both have setMaxSerial methods that are theoretically used for per-telm channel and per-event string truncation, but we should have a discussion about if that functionality is necessary and if there's better ways to accomplish it.