[PATCH] D46845: [libcxx][c++17] P0083R5: Splicing Maps and Sets

Marshall Clow via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 15 09:29:57 PDT 2018


mclow.lists added a comment.

>> One way we could deal with this is by adding an attribute to the compiler to indicate "the const is a lie", that we can apply to std::pair::first, with the semantics being that a top-level const is ignored when determining the "real" type of the member (and so mutating the member after a const_cast has defined behavior). This would apply to all std::pairs, not just the node_handle case, but in practice we don't optimize on the basis of a member being declared const *anyway*, so this isn't such a big deal right now.
> 
> I'm a fan of this idea, this would also have the bonus of fixing some pre-existing type-punning between pair<const K, V> and pair<K, V> (see __hash_value_type and __value_type in <unordered_map> and <map>).

This was //supposed// to be taken care of by [class.mem]/21 (common initial sequence), but that foundered on "standard-layout".


https://reviews.llvm.org/D46845





More information about the cfe-commits mailing list