diff --git a/DataFormats/simulation/include/SimulationDataFormat/ConstMCTruthContainer.h b/DataFormats/simulation/include/SimulationDataFormat/ConstMCTruthContainer.h index 72c66c863f698..50c42237f5f26 100644 --- a/DataFormats/simulation/include/SimulationDataFormat/ConstMCTruthContainer.h +++ b/DataFormats/simulation/include/SimulationDataFormat/ConstMCTruthContainer.h @@ -20,6 +20,7 @@ #ifndef GPUCA_STANDALONE #include #endif +#include class TTree; @@ -132,7 +133,7 @@ template class ConstMCTruthContainerView { public: - ConstMCTruthContainerView(gsl::span const bufferview) : mStorage(bufferview){}; + ConstMCTruthContainerView(std::span const bufferview) : mStorage(bufferview.data(), bufferview.size()) {}; ConstMCTruthContainerView(ConstMCTruthContainer const& cont) : mStorage(gsl::span(cont)){}; // be explicit that we want nullptr / 0 for an uninitialized container (needs (void)0 to avoid false codechecker warning) ConstMCTruthContainerView() : mStorage{nullptr, static_cast::size_type>(0)} diff --git a/Detectors/CPV/simulation/src/RawWriter.cxx b/Detectors/CPV/simulation/src/RawWriter.cxx index bed3a4b51f4a6..caad5b4f19cb9 100644 --- a/Detectors/CPV/simulation/src/RawWriter.cxx +++ b/Detectors/CPV/simulation/src/RawWriter.cxx @@ -189,7 +189,7 @@ bool RawWriter::processOrbit(const gsl::span digitsbranch, const } } mRawWriter->addData(links[iLink].feeId, links[iLink].cruId, links[iLink].linkId, links[iLink].endPointId, currentIR, - gsl::span(mPayload[iLink].data(), mPayload[iLink].size()), preformatted); + std::span(mPayload[iLink].data(), mPayload[iLink].size()), preformatted); mPayload[iLink].clear(); cpvWordCounter[iLink] = 0; cpvWordCounterBeforeCPVTrailer[iLink] = 0; @@ -262,7 +262,7 @@ bool RawWriter::processOrbit(const gsl::span digitsbranch, const } } mRawWriter->addData(links[iLink].feeId, links[iLink].cruId, links[iLink].linkId, links[iLink].endPointId, currentIR, - gsl::span(mPayload[iLink].data(), mPayload[iLink].size()), preformatted); + std::span(mPayload[iLink].data(), mPayload[iLink].size()), preformatted); mPayload[iLink].clear(); cpvWordCounter[iLink] = 0; @@ -322,7 +322,7 @@ bool RawWriter::processOrbit(const gsl::span digitsbranch, const } } mRawWriter->addData(links[iLink].feeId, links[iLink].cruId, links[iLink].linkId, links[iLink].endPointId, currentIR, - gsl::span(mPayload[iLink].data(), mPayload[iLink].size()), preformatted); + std::span(mPayload[iLink].data(), mPayload[iLink].size()), preformatted); mPayload[iLink].clear(); cpvWordCounter[iLink] = 0; @@ -373,7 +373,7 @@ bool RawWriter::processOrbit(const gsl::span digitsbranch, const } } mRawWriter->addData(links[iLink].feeId, links[iLink].cruId, links[iLink].linkId, links[iLink].endPointId, - trgs.back().getBCData(), gsl::span(mPayload[iLink].data(), mPayload[iLink].size()), preformatted); + trgs.back().getBCData(), std::span(mPayload[iLink].data(), mPayload[iLink].size()), preformatted); mPayload[iLink].clear(); } } diff --git a/Detectors/GlobalTracking/include/GlobalTracking/TrackMethods.h b/Detectors/GlobalTracking/include/GlobalTracking/TrackMethods.h index f65d9ffd260e6..b5baab2d43857 100644 --- a/Detectors/GlobalTracking/include/GlobalTracking/TrackMethods.h +++ b/Detectors/GlobalTracking/include/GlobalTracking/TrackMethods.h @@ -20,6 +20,7 @@ #include "GPUTPCGMMergedTrackHit.h" #include "DataFormatsITS/TrackITS.h" #include +#include #include namespace o2 diff --git a/Detectors/HMPID/simulation/src/HmpidCoder2.cxx b/Detectors/HMPID/simulation/src/HmpidCoder2.cxx index c96b7485bc8cd..d081641ce9ee0 100644 --- a/Detectors/HMPID/simulation/src/HmpidCoder2.cxx +++ b/Detectors/HMPID/simulation/src/HmpidCoder2.cxx @@ -186,7 +186,7 @@ void HmpidCoder2::writePaginatedEvent(uint32_t orbit, uint16_t bc) ReadOut::LnkId(eq), 0, {bc, orbit}, - gsl::span(reinterpret_cast(ptrStartEquipment), + std::span(reinterpret_cast(ptrStartEquipment), EventSize * sizeof(uint32_t)), false, 0, diff --git a/Detectors/ITSMFT/common/simulation/src/MC2RawEncoder.cxx b/Detectors/ITSMFT/common/simulation/src/MC2RawEncoder.cxx index 417178f723a24..18c5570d1a0d2 100644 --- a/Detectors/ITSMFT/common/simulation/src/MC2RawEncoder.cxx +++ b/Detectors/ITSMFT/common/simulation/src/MC2RawEncoder.cxx @@ -222,7 +222,7 @@ void MC2RawEncoder::fillGBTLinks(RUDecodeData& ru) LOGF(debug, "Filled %s with %d GBT words", link->describe(), nPayLoadWordsNeeded + 3); // flush to writer - mWriter.addData(link->feeID, link->cruID, link->idInCRU, link->endPointID, mCurrIR, gsl::span((char*)link->data.data(), link->data.getSize())); + mWriter.addData(link->feeID, link->cruID, link->idInCRU, link->endPointID, mCurrIR, std::span((char*)link->data.data(), link->data.getSize())); link->data.clear(); // } // loop over links of RU diff --git a/Detectors/MUON/MCH/Raw/Encoder/Payload/PayloadPaginator.cxx b/Detectors/MUON/MCH/Raw/Encoder/Payload/PayloadPaginator.cxx index f11467098945e..41ec16dacdf66 100644 --- a/Detectors/MUON/MCH/Raw/Encoder/Payload/PayloadPaginator.cxx +++ b/Detectors/MUON/MCH/Raw/Encoder/Payload/PayloadPaginator.cxx @@ -136,7 +136,7 @@ void paginate(o2::raw::RawFileWriter& rawFileWriter, filled[o2::InteractionRecord{h.bc, h.orbit}].insert(li.value()); rawFileWriter.addData(rdhFromLinkInfo(li.value()), {h.bc, h.orbit}, - gsl::span(const_cast(reinterpret_cast(&b.payload[0])), + std::span(const_cast(reinterpret_cast(&b.payload[0])), b.payload.size())); } diff --git a/Detectors/Raw/include/DetectorsRaw/RawFileWriter.h b/Detectors/Raw/include/DetectorsRaw/RawFileWriter.h index 1f4632d273bfc..c324011570284 100644 --- a/Detectors/Raw/include/DetectorsRaw/RawFileWriter.h +++ b/Detectors/Raw/include/DetectorsRaw/RawFileWriter.h @@ -17,6 +17,7 @@ /// @brief Utility class to write detectors data to (multiple) raw data file(s) respecting CRU format #include +#include #include #include #include @@ -205,10 +206,10 @@ class RawFileWriter } void addData(uint16_t feeid, uint16_t cru, uint8_t lnk, uint8_t endpoint, const IR& ir, - const gsl::span data, bool preformatted = false, uint32_t trigger = 0, uint32_t detField = 0); + const std::span data, bool preformatted = false, uint32_t trigger = 0, uint32_t detField = 0); template - void addData(const H& rdh, const IR& ir, const gsl::span data, bool preformatted = false, uint32_t trigger = 0) + void addData(const H& rdh, const IR& ir, const std::span data, bool preformatted = false, uint32_t trigger = 0) { RDHAny::sanityCheckLoose(); addData(RDHUtils::getFEEID(rdh), RDHUtils::getCRUID(rdh), RDHUtils::getLinkID(rdh), RDHUtils::getEndPointID(rdh), ir, data, trigger); diff --git a/Detectors/Raw/src/RawFileWriter.cxx b/Detectors/Raw/src/RawFileWriter.cxx index d7a0aae7fe47e..d07b0fa98fec8 100644 --- a/Detectors/Raw/src/RawFileWriter.cxx +++ b/Detectors/Raw/src/RawFileWriter.cxx @@ -177,7 +177,7 @@ RawFileWriter::LinkData& RawFileWriter::registerLink(uint16_t fee, uint16_t cru, } //_____________________________________________________________________ -void RawFileWriter::addData(uint16_t feeid, uint16_t cru, uint8_t lnk, uint8_t endpoint, const IR& ir, const gsl::span data, bool preformatted, uint32_t trigger, uint32_t detField) +void RawFileWriter::addData(uint16_t feeid, uint16_t cru, uint8_t lnk, uint8_t endpoint, const IR& ir, const std::span data, bool preformatted, uint32_t trigger, uint32_t detField) { // add payload to relevant links auto sspec = RDHUtils::getSubSpec(cru, lnk, endpoint, feeid); diff --git a/Detectors/TOF/reconstruction/src/Encoder.cxx b/Detectors/TOF/reconstruction/src/Encoder.cxx index b761a10ca2b38..34d882f63dd74 100644 --- a/Detectors/TOF/reconstruction/src/Encoder.cxx +++ b/Detectors/TOF/reconstruction/src/Encoder.cxx @@ -114,7 +114,7 @@ bool Encoder::flush(int icrate) if (nbyte) { if (mCrateOn[icrate]) { //printf("flush crate %d -- byte = %d -- orbit = %d, bc = %d\n",icrate, nbyte, mIR.orbit, mIR.bc); - mFileWriter.addData(Geo::getFEEid(icrate), Geo::getCRUid(icrate), Geo::getCRUlink(icrate), Geo::getCRUendpoint(icrate), mIR, gsl::span(mBuffer[icrate], nbyte)); + mFileWriter.addData(Geo::getFEEid(icrate), Geo::getCRUid(icrate), Geo::getCRUlink(icrate), Geo::getCRUendpoint(icrate), mIR, std::span(mBuffer[icrate], nbyte)); } mIntegratedAllBytes += nbyte; } diff --git a/Detectors/TPC/workflow/src/ClusterDecoderRawSpec.cxx b/Detectors/TPC/workflow/src/ClusterDecoderRawSpec.cxx index c5c444e077703..0362eafb38614 100644 --- a/Detectors/TPC/workflow/src/ClusterDecoderRawSpec.cxx +++ b/Detectors/TPC/workflow/src/ClusterDecoderRawSpec.cxx @@ -111,7 +111,7 @@ DataProcessorSpec getClusterDecoderRawSpec(bool sendMC) std::vector mcinCopiesFlatView; ConstMCLabelContainerView mcin; if (DataRefUtils::isValid(mclabelref)) { - mcin = pc.inputs().get>(mclabelref); + mcin = pc.inputs().get>(mclabelref); mcinCopiesFlat.resize(nPages); mcinCopiesFlatView.reserve(nPages); if (verbosity > 0) { diff --git a/Detectors/TPC/workflow/src/ClustererSpec.cxx b/Detectors/TPC/workflow/src/ClustererSpec.cxx index 310551a67753e..00ce52658bf73 100644 --- a/Detectors/TPC/workflow/src/ClustererSpec.cxx +++ b/Detectors/TPC/workflow/src/ClustererSpec.cxx @@ -89,7 +89,7 @@ DataProcessorSpec getClustererSpec(bool sendMC) } ConstMCLabelContainerView inMCLabels; if (DataRefUtils::isValid(mclabelref)) { - inMCLabels = pc.inputs().get>(mclabelref); + inMCLabels = pc.inputs().get>(mclabelref); } auto inDigits = pc.inputs().get>(dataref); if (verbosity > 0 && inMCLabels.getBuffer().size()) { diff --git a/Detectors/TPC/workflow/src/ZSSpec.cxx b/Detectors/TPC/workflow/src/ZSSpec.cxx index eaedb537faba8..3fb13d520cdea 100644 --- a/Detectors/TPC/workflow/src/ZSSpec.cxx +++ b/Detectors/TPC/workflow/src/ZSSpec.cxx @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include "GPUO2InterfaceUtils.h" diff --git a/Framework/Core/include/Framework/InputRecord.h b/Framework/Core/include/Framework/InputRecord.h index dc8d8455bb418..7e678a6e9a67a 100644 --- a/Framework/Core/include/Framework/InputRecord.h +++ b/Framework/Core/include/Framework/InputRecord.h @@ -303,7 +303,6 @@ class InputRecord // implementation (f) } else if constexpr (is_span::value) { // substitution for span of messageable objects - // FIXME: there will be std::span in C++20 static_assert(is_messageable::value, "span can only be created for messageable types"); auto header = DataRefUtils::getHeader(ref); assert(header); @@ -318,7 +317,8 @@ class InputRecord " payload size " + std::to_string(payloadSize)) .c_str()); } - return gsl::span(reinterpret_cast(ref.payload), payloadSize / sizeof(ValueT)); + using SpanT = std::conditional_t>, std::span, gsl::span>; + return SpanT(reinterpret_cast(ref.payload), payloadSize / sizeof(ValueT)); // implementation (g) } else if constexpr (is_container::value) { diff --git a/Framework/Core/include/Framework/TypeTraits.h b/Framework/Core/include/Framework/TypeTraits.h index bb2d338f42af3..4ebc2651a30bc 100644 --- a/Framework/Core/include/Framework/TypeTraits.h +++ b/Framework/Core/include/Framework/TypeTraits.h @@ -17,6 +17,7 @@ #include "Framework/Traits.h" #include +#include namespace o2::framework { @@ -60,6 +61,9 @@ struct is_messageable : std::conditional<(std::is_trivially_copyable::value | template struct is_messageable> : std::false_type { }; +template +struct is_messageable> : std::false_type { +}; // Detect a container by checking on the container properties // this is the default trait implementation inheriting from false_type @@ -107,7 +111,7 @@ template struct is_span : std::false_type { }; template -struct is_span> : std::is_same, T> { +struct is_span> : std::bool_constant, T> || std::is_same_v, T>> { }; // Detect whether a class has a ROOT dictionary diff --git a/Framework/Core/test/test_TypeTraits.cxx b/Framework/Core/test/test_TypeTraits.cxx index 5d38ca33c137c..58958b8e71fa5 100644 --- a/Framework/Core/test/test_TypeTraits.cxx +++ b/Framework/Core/test/test_TypeTraits.cxx @@ -135,9 +135,12 @@ TEST_CASE("TestIsSpan") gsl::span a; int b; std::vector c; + std::span d; REQUIRE(is_span::value == true); REQUIRE(is_span::value == false); REQUIRE(is_span::value == false); + REQUIRE(is_span::value == true); + REQUIRE(is_messageable::value == false); } template