Date: Fri, 25 Aug 2023 17:14:15 +0200
pt., 25 sie 2023 o 17:08 Hewill Kang via Std-Proposals
<std-proposals_at_[hidden]> napisaĆ(a):
>
> Hi all experts,
>
> boost::compressed_pair is widely used as a replacement for std::pair in order to save storage when one of the data members is an empty class.
>
> The __compressed_pair helper class, which is similar to boost::compressed_pair, is also widely used in libc++.
>
> I wonder if we could get this compression optimization at almost no cost if add the C++ [[no_unique_address]] attribute to the members of std::pair:
>
> namespace std {
> template<class T1, class T2>
> struct pair {
> using first_type = T1;
> using second_type = T2;
>
> [[no_unique_address]] T1 first; // <- here
> [[no_unique_address]] T2 second; // <- here
> };
> }
>
> This looks reasonable to me, and almost achieves the equivalent of boost::compressed_pair.
>
> What do you guys think about this? This seems like a great enhancement to me. Or does this kind of practice bring certain issues?
>
Probably the biggest problem is ABI compatibility, any compiler that
decides to change this will force everyone
to recompile their code from sources and this is sometimes impossible
if you have access only to compiled binaries.
> Comments are very welcome.
>
> Hewill
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
<std-proposals_at_[hidden]> napisaĆ(a):
>
> Hi all experts,
>
> boost::compressed_pair is widely used as a replacement for std::pair in order to save storage when one of the data members is an empty class.
>
> The __compressed_pair helper class, which is similar to boost::compressed_pair, is also widely used in libc++.
>
> I wonder if we could get this compression optimization at almost no cost if add the C++ [[no_unique_address]] attribute to the members of std::pair:
>
> namespace std {
> template<class T1, class T2>
> struct pair {
> using first_type = T1;
> using second_type = T2;
>
> [[no_unique_address]] T1 first; // <- here
> [[no_unique_address]] T2 second; // <- here
> };
> }
>
> This looks reasonable to me, and almost achieves the equivalent of boost::compressed_pair.
>
> What do you guys think about this? This seems like a great enhancement to me. Or does this kind of practice bring certain issues?
>
Probably the biggest problem is ABI compatibility, any compiler that
decides to change this will force everyone
to recompile their code from sources and this is sometimes impossible
if you have access only to compiled binaries.
> Comments are very welcome.
>
> Hewill
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2023-08-25 15:14:27