FairRoot
FairRoot copied to clipboard
Change operator< from FairTimeStamp* to FairTimeStamp&
The behaviour of the FairTimeStamp::operator< does no follow standard behaviour by dealing with the FairTimeStamp* instead of a FairTimeStamp&. This is fixed in this merge request. Should fix issue #1519.
Describe your proposal.
Mention any issue this PR resolves or is related to.
Checklist:
- [ ] Followed the Contributing Guidelines
Summary by CodeRabbit
-
Refactor
- Updated the comparison method in the timestamp functionality to enhance reliability and performance.
Walkthrough
Walkthrough
The recent update in the FairRoot project involves modifying the operator<
method in the FairTimeStamp
class to use a reference instead of a pointer. This change aims to enhance the method's usability and address compatibility issues with newer compiler versions that have stricter overload rules.
Changes
File Path | Change Summary |
---|---|
fairroot/base/event/FairTimeStamp.h |
Changed operator< from taking a pointer to taking a reference. |
Possibly related issues
-
FairRootGroup/FairRoot#1519: The change to
operator<
inFairTimeStamp
might resolve the compiler warning about hidden overloaded virtual function, as the method signature now properly differentiates from similar methods in derived classes.
Recent Review Details
Configuration used: CodeRabbit UI Review profile: CHILL
Commits
Files that changed from the base of the PR and between 5c154f07fe61d1bea877483e623580b1879d2e49 and e891df5c270be9c1a53c693dd027d9bce1b90e8d.Files selected for processing (1)
- fairroot/base/event/FairTimeStamp.h (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- fairroot/base/event/FairTimeStamp.h
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>.
-
Generate unit testing code for this file.
-
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitai
in a new review comment at the desired location with your query. Examples:-
@coderabbitai generate unit testing code for this file.
-
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitai
in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai generate interesting stats about this repository and render them as a table.
-
@coderabbitai show all the console.log statements in this repository.
-
@coderabbitai read src/utils.ts and generate unit testing code.
-
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
-
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
-
@coderabbitai pause
to pause the reviews on a PR. -
@coderabbitai resume
to resume the paused reviews. -
@coderabbitai review
to trigger a review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai resolve
resolve all the CodeRabbit review comments. -
@coderabbitai help
to get help.
Additionally, you can add @coderabbitai ignore
anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml
)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yaml
file to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
@TobiasStockmanns,
I don't understand why the operator is needed at all. I is neither used in FairRoot nor PandaRoot which was checked by Radek and me independently. Radek simply removed the function, I add the function with =delete
. In both cases we did not see any compilation errors. To cross-check I add a test which uses the operator< and this file shows the following error message during compilation
/opt/fairroot/source/v19.0/tests/base/event/test_FairTimeStamp.cxx:20:9: error: overload resolution selected deleted operator '<'
if (a<b) { a=2.;}
~^~
/opt/fairroot/source/v19.0/fairroot/base/event/FairTimeStamp.h:63:11: note: candidate function has been explicitly deleted
bool operator<(const FairTimeStamp& rValue) = delete;
^
/opt/fairsoft/jan24/include/root/TString.h:778:15: note: candidate function not viable: no known conversion from 'FairTimeStamp' to 'const TString' for 1st argument
inline Bool_t operator<(const TString &s1, const TString &s2)
^
/opt/fairsoft/jan24/include/root/TString.h:794:15: note: candidate function not viable: no known conversion from 'FairTimeStamp' to 'const TString' for 1st argument
inline Bool_t operator<(const TString &s1, const char *s2)
^
/opt/fairsoft/jan24/include/root/TString.h:812:15: note: candidate function not viable: no known conversion from 'FairTimeStamp' to 'const char *' for 1st argument
inline Bool_t operator<(const char *s1, const TString &s2)
^
/opt/fairroot/source/v19.0/fairroot/base/event/FairTimeStamp.h:64:11: note: candidate function not viable: no known conversion from 'FairTimeStamp' to 'const FairTimeStamp *' for 1st argument; take the address of the argument with &
bool operator<(const FairTimeStamp* rValue) = delete;
^
I don't see the need for the overloaded function and would propose to simply delete it or at least set it as deprecated.
The original idea why I defined bool operator<(const FairTimeStamp* rValue)
was to be able to sort a container of FairTimeStamp*
with this operator. Unfortunately this does not work because the sort will always use the memory location and not the FairTimeStamp::operator<
. So this implementation does not make any sense.
Nevertheless I think it is good to have an bool operator<(const FairTimeStamp& rValue)
defined, because for time based simulations and reconstructions a sorting by the time stamp is mandatory and this should be supported by the code.
In addition the virtual
should be removed.
@coderabbitai construct short CHANGELOG message for this PR. @TobiasStockmanns , can you squash into one commit?
[!TIP] For best results, initiate chat on the files or code changes.
@karabowi, here's a short CHANGELOG message for PR #1526:
- Updated `FairTimeStamp::operator<` to use references instead of pointers, aligning with standard C++ practices and enhancing safety. This change supports accurate timestamp-based sorting in simulations and reconstructions.
Let me know if you need any further modifications or additional information!