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.
The compiler is free to reorder members within a class regardless of the order they were declared in. No implementations do (that I know of), but we aren't asking about implementations.
-
-
I guess, all that being said, I gave it a shot in godbolt with -fsanitize=undefined and it didn't return any errors. *shrug*. If it were me, I'd use a span<int const *>.
-
At risk of inciting a mob, those who follow
@lefticus may be best equipped to answer this. - Näytä vastaukset
Uusi keskustelu -
-
-
Um. Are you sure that's true?! I think it's allowed to reorder access specifier blocks but not the variables defined within said blocks. My knowledge of the standard is rusty though.
-
Oof. You may be right. Now that you mentione it, I recall it mostly being related to access specifier blocks as well.
Keskustelun loppu
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.