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

edmNew::DetSetVector and edmNew::DetSet are not fully const-correct #46917

Open
makortel opened this issue Dec 11, 2024 · 4 comments
Open

edmNew::DetSetVector and edmNew::DetSet are not fully const-correct #46917

makortel opened this issue Dec 11, 2024 · 4 comments

Comments

@makortel
Copy link
Contributor

As shown in

edmNew::DetSetVector<SiStripCluster>::const_iterator isearch =
cluster_detsetvektor->find(detid); // search clusters of detid

edmNew::DetSet<SiStripCluster> cluster_detset = (*isearch);

one can get a non-const edmNew::DetSet<T> by de-referencing an edmNew::DetSetVector<T>::const_iterator.

The problems stem from edmNew::DetSet<T> being a proxy type, i.e. it contains a pointer to the container held by the corresponding edmNew::DetSetVector, and necessary offset there

id_type m_id;
DataContainer const *m_data;
int m_offset;
size_type m_size;

and it providing both const and non-const interface.

One specific problem is that (assuming I understood the behavior of boost::transform_iterator correctly, the

result_type operator()(Item const& item) const { return result_type(*m_v, item, m_update); }

returns a non-const edmNew::DetSet. On the other hand, returning const edmNew::DetSet wouldn't help, because edmNew::DetSet has default copy (and move) constructor/assignment, and therefore one can easily copy a const edmNew::DetSet into a non-const edmNew::DetSet.

On a quick though I think the only certain way out would be to have separate "DetSet" types for the const and non-const access of the edmNew::DetSetVector.

@makortel
Copy link
Contributor Author

assign core

@cmsbuild
Copy link
Contributor

New categories assigned: core

@Dr15Jones,@makortel,@smuzaffar you have been requested to review this Pull request/Issue and eventually sign? Thanks

@cmsbuild
Copy link
Contributor

cms-bot internal usage

@cmsbuild
Copy link
Contributor

A new Issue was created by @makortel.

@Dr15Jones, @antoniovilela, @makortel, @mandrenguyen, @rappoccio, @sextonkennedy, @smuzaffar can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants