Skip to content
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++20 #168

Merged
merged 8 commits into from
May 30, 2023
Merged

C++20 #168

merged 8 commits into from
May 30, 2023

Conversation

andresailer
Copy link
Contributor

@andresailer andresailer commented May 22, 2023

BEGINRELEASENOTES

  • Pregenerated Headers: remove self-include from some headers (breaks include-what-you-use)
  • LCIterator, LCRTRelations: remove template syntax causing errors in gcc13/c++20
  • RunEvent, LCObject, TrackStateImpl: added default copy and move constructor and assignment operator to avoid error about "'definition of implicit copy constructor for 'LCObject' is deprecated because it has a user-declared destructor'"

ENDRELEASENOTES

Fixes for example

In file included from /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/LCIO-02.16.01/src/LCIO/02.16.01/src/cpp/include/pre-generated/EVENT/LCObject.h:10,
                 from /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/LCIO-02.16.01/src/LCIO/02.16.01/src/cpp/include/IMPL/LCCollectionVec.h:8,
                 from /build/jenkins/workspace/lcg_nightly_pipeline/build/projects/LCIO-02.16.01/src/LCIO/02.16.01/src/cpp/src/IMPL/LCCollectionVec.cc:2:
/build/jenkins/workspace/lcg_nightly_pipeline/build/projects/LCIO-02.16.01/src/LCIO/02.16.01/src/cpp/include/LCRTRelations.h:72:33: error: expected unqualified-id before 'const'
   72 |     LCBaseTraits<U, T, I, D, b>(const LCBaseTraits&) = delete ;
      |                                 ^~~~~
/build/jenkins/workspace/lcg_nightly_pipeline/build/projects/LCIO-02.16.01/src/LCIO/02.16.01/src/cpp/include/LCRTRelations.h:72:33: error: expected ')' before 'const'
   72 |     LCBaseTraits<U, T, I, D, b>(const LCBaseTraits&) = delete ;
      |                                ~^~~~~
      |                                 )
/build/jenkins/workspace/lcg_nightly_pipeline/build/projects/LCIO-02.16.01/src/LCIO/02.16.01/src/cpp/include/LCRTRelations.h:82:12: error: template-id not allowed for destructor
   82 |     inline ~LCBaseTraits<U, T, I, D, b>() {
      |            ^
/build/jenkins/workspace/lcg_nightly_pipeline/build/projects/LCIO-02.16.01/src/LCIO/02.16.01/src/cpp/include/LCRTRelations.h:271:23: error: expected unqualified-id before ')' token
  271 |     LCIntExtension<U>() = default ;
      |                       ^
/build/jenkins/workspace/lcg_nightly_pipeline/build/projects/LCIO-02.16.01/src/LCIO/02.16.01/src/cpp/include/LCRTRelations.h:275:5: error: template-id not allowed for destructor
  275 |     ~LCIntExtension<U>() = default ;
      |     ^
/build/jenkins/workspace/lcg_nightly_pipeline/build/projects/LCIO-02.16.01/src/LCIO/02.16.01/src/cpp/include/LCRTRelations.h:304:25: error: expected unqualified-id before ')' token
  304 |     LCFloatExtension<U>() = default ;
      |                         ^
/build/jenkins/workspace/lcg_nightly_pipeline/build/projects/LCIO-02.16.01/src/LCIO/02.16.01/src/cpp/include/LCRTRelations.h:308:5: error: template-id not allowed for destructor
  308 |     ~LCFloatExtension<U>() = default ;
      |     ^
/build/jenkins/workspace/lcg_nightly_pipeline/build/projects/LCIO-02.16.01/src/LCIO/02.16.01/src/cpp/include/LCRTRelations.h:330:24: error: expected unqualified-id before ')' token
  330 |     LCBoolExtension<U>() = default ;
      |                        ^
/build/jenkins/workspace/lcg_nightly_pipeline/build/projects/LCIO-02.16.01/src/LCIO/02.16.01/src/cpp/include/LCRTRelations.h:334:5: error: template-id not allowed for destructor
  334 |     ~LCBoolExtension<U>() = default ;
      |     ^

Copy link
Contributor

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already looks good. Just some nit-picking from my side since we are already at it.

LCObject() = default ;
LCObject(LCObject const&) = default ;
LCObject& operator=(LCObject const&) = default ;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the move constructors here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was no error about missing or implicitly defined move constructors.
Should I add them with default?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not entirely trivial in this case on whether it will be implicitly defaulted, or implicitly deleted in the cases that we have here: https://en.cppreference.com/w/cpp/language/move_constructor

For LCObject and in general for all the abstract interfaces I think explicitly defaulting them should be fine, IIUC. (At least then they should not prevent anything in the Impl classes).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the default move constructors.

@@ -27,8 +27,7 @@ class TrackState : public LCObject {

public:
/// Destructor.
virtual ~TrackState() = default;

//virtual ~TrackState() { /* nop */; } // implicit!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//virtual ~TrackState() { /* nop */; } // implicit!
//virtual ~TrackState() = default; // implicit!

Personal preference for indicating that this is no-op. On the other hand we could also entirely remove the commented one here, c.f. rule of 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the commenting, this change is because I didn't start from the HEAD of master and the line was actually changed, and when I solved the conflict I just took the line from my changes. Yes, completely removing is fine of course

PS: cf. is one word, cf. https://en.wikipedia.org/wiki/Cf. /nitpick

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the commented line

@@ -15,6 +15,8 @@ namespace SIO {
typedef long long long64 ;

RunEvent() = default ;
RunEvent(RunEvent const&) = default ;
RunEvent& operator=(RunEvent const&) = default ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about move constructors here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@@ -27,6 +27,8 @@ namespace IMPL {
/** Default constructor, initializes values to 0.
*/
TrackStateImpl() ;
TrackStateImpl(TrackStateImpl const&) = default ;
TrackStateImpl& operator=(TrackStateImpl const&) = default ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different class, same question: What about move constructors here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@tmadlener tmadlener merged commit da3bd4a into iLCSoft:master May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants