Skip to content
Snippets Groups Projects
Commit 87180c1b authored by scott snyder's avatar scott snyder Committed by scott snyder
Browse files

GeneratorObjects: Fix compilation with c++20.

With c++20, GenParticle*==HepMcParticleLink was ambiguous.

 - The second argument could convert to GenParticle* and then compare using
   the built-in == operation.
 - The first argument could convert to HepMcParticleLink and the compare
   using HepMcParticleLink::operator==.

The second of these is only allowed in c++20 due to the fact that operator==
is implicitly reversable (otherwise, we wouldn't be able to convert the
first argument as this is a member function).

Add an explicit operator== for this case to disambiguate (choosing the first
alternative).
parent 1b08b314
6 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!39549GeneratorObjects: Fix compilation with c++20.
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
*/
#ifndef GENERATOROBJECTS_HEPMCPARTICLELINK_H
......@@ -665,6 +665,16 @@ public:
};
/**
* @brief Comparison with GenParticle*.
* Needed with c++20 to break an ambiguity between the built-in GenParticle*
* equality and operator== defined above, arising due to the conversions
* back and forth between HepMcParticleLink and GenParticle*.
*/
bool operator== (const HepMC::GenParticle* a,
const HepMcParticleLink& b);
/**
* @brief Output operator.
* @param os Stream to which to output.
......
/*
* Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration.
* Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration.
*/
/**
* @file GeneratorObjects/HepMcParticleLink.icc
......@@ -600,3 +600,17 @@ HepMcParticleLink::barcode_type HepMcParticleLink::compress() const
return ( ((m_extBarcode.barcode()&0xFFFF) << 16) |
eventIndex() );
}
/**
* @brief Comparison with GenParticle*.
* Needed with c++20 to break an ambiguity between the built-in GenParticle*
* equality and operator== defined above, arising due to the conversions
* back and forth between HepMcParticleLink and GenParticle*.
*/
inline
bool operator== (const HepMC::GenParticle* a,
const HepMcParticleLink& b)
{
return a == b.cptr();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment