Skip to content

Commit

Permalink
Merge pull request #48 from art-daq/eflumerf/FixFragmentCopy
Browse files Browse the repository at this point in the history
Fix Fragment Copy constructor and assignment operator to ensure that
  • Loading branch information
ron003 authored Mar 5, 2024
2 parents 52a5ac1 + 54230f8 commit 7d6acf8
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions artdaq-core/Data/Fragment.hh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public:
* \brief Default copy constructor
* \todo Decide if Copy constructor should be declared =delete
*/
Fragment(const Fragment&) = default;
Fragment(const Fragment&);
/**
* \brief Move Constructor
*
Expand All @@ -122,7 +122,7 @@ public:
* \return Reference to new Fragment
* \todo Decide if copy-assignment operator should be declared =delete
*/
Fragment& operator=(const Fragment&) = default;
Fragment& operator=(const Fragment&);
/**
* \brief Move-assignment operator
* \return Reference to Fragment
Expand Down Expand Up @@ -768,8 +768,24 @@ private:

// http://stackoverflow.com/questions/33939687
// This should generate an exception if artdaq::Fragment is not move-constructible
inline artdaq::Fragment::Fragment(artdaq::Fragment&&) noexcept = default;
inline artdaq::Fragment& artdaq::Fragment::operator=(artdaq::Fragment&&) noexcept = default;
inline artdaq::Fragment::Fragment(artdaq::Fragment&& of) noexcept : vals_(std::move(of.vals_)), upgraded_header_(of.upgraded_header_) {
of.upgraded_header_ = nullptr;
}
inline artdaq::Fragment& artdaq::Fragment::operator=(artdaq::Fragment&& of) noexcept
{
vals_ = std::move(of.vals_);
upgraded_header_ = of.upgraded_header_;
of.upgraded_header_ = nullptr;
return *this;
}


inline artdaq::Fragment::Fragment(const artdaq::Fragment& f) : vals_(f.vals_), upgraded_header_(nullptr) {}
inline artdaq::Fragment& artdaq::Fragment::operator=(const artdaq::Fragment& f) {
vals_ = f.vals_;
upgraded_header_ = nullptr;
return *this;
}

inline bool constexpr artdaq::Fragment::
isUserFragmentType(type_t fragmentType)
Expand Down

0 comments on commit 7d6acf8

Please sign in to comment.