Skip to content

Fix gcc7 compilation error

Marco Cattaneo requested to merge fixgcc7Compilation into master

Fix gcc7 compilation error

/build/jenkins-build/workspace/nightly-builds/build/build/REC/REC_HEAD/Tf/TfKernel/TfKernel/DefaultVeloHitManager.h:249:21: error: no matching function for call to 'transform(std::vector<Tf::VeloPhiHit, std::allocator<Tf::VeloPhiHit> >::iterator, std::vector<Tf::VeloPhiHit, std::allocator<Tf::VeloPhiHit> >::iterator, std::back_insert_iterator<std::vector<Tf::VeloPhiHit*> >, <unresolved overloaded function type>)'

by replacing

std::transform( begin(source), end(source), std::back_inserter(target), std::addressof<HIT> );

with

std::transform( begin(source), end(source), std::back_inserter(target), [](auto& hit) { return &hit; } );

@graven's explanation:

There used to be only a template< class T > T* addressof(T& arg) noexcept; so std::addressof<HIT> was unambiguous.

But then, in C++17, they added something that makes it impossible to pass a temporary to addressof, which would result in the address of something that doesn’t exist anymore after the call, by adding

template <class T>
const T* addressof(const T&&) = delete;

So at this point, when the compiler sees std::addressof, there are two functions it can choose — the fact that the second one is actually explicitly deleted, and hence doesn’t exist isn’t relevant at this point…

Edited by Marco Cattaneo

Merge request reports