I guess I'll throw in my (unverified) observation. vector<int*> and vector<int const*> are two unrelated types, regardless of the relationship of the types they contain, and as such the cast is UB.
At risk of inciting a mob, those who follow @lefticus may be best equipped to answer this.
-
-
Yes, they are two completely unrelated types, and it is UB. Breaks strong aliasing rules. Most uses of const_cast enable UB and almost all uses of reinterpret_cast result in UB, and your c-style cast is a reinterpret_cast. I'll let
@shafikyaghmour link his articles -
So what's the most performant way to get a const version of those pointers in an array format? Std::span? And before c++20?
- Näytä vastaukset
Uusi keskustelu -
Lataaminen näyttää kestävän hetken.
Twitter saattaa olla ruuhkautunut tai ongelma on muuten hetkellinen. Yritä uudelleen tai käy Twitterin tilasivulla saadaksesi lisätietoja.