Telegram Group & Telegram Channel
Compressed pair

В стандартной библиотеке C++ множество контейнеров принимают allocator<A>, который по дефолту занимает 0 байт. Но в C++ не могут быть структуры (в отличие от C) с sizeof равным нулю. Значит элементами класса их не сделать бесплатно. В итоге приходилось использовать Empty Base Optimization, когда наследование от класса с нулевым размером оптимизируется в void.
Чтобы это как-то унифицировать, в libc++ сделали compressed_pair<A, B>, чтобы можно было писать члены класса и зафиксировать ABI. Делали A каким-то нужным полем, а B, например, аллокатором, тем самым sizeof сохранялся.

В C++20 добавили атрибут [[no_unique_address]], который запрещает адресоваться к структурам размера ноль, а если более точно, то при попытке так сделать даст какой-то адрес какого-то члена класса.

Спустя 4 года завезли в libc++ и заменили compressed_pair. Патч тащили 9 месяцев, потому что поломалось всё в дебагерах. Дотащили, дебаг символы в хромиум уменьшились на 5%, компиляция ускорилась на 1-1.5%, что не может не радовать.

https://github.com/llvm/llvm-project/pull/76756



group-telegram.com/experimentalchill/283
Create:
Last Update:

Compressed pair

В стандартной библиотеке C++ множество контейнеров принимают allocator<A>, который по дефолту занимает 0 байт. Но в C++ не могут быть структуры (в отличие от C) с sizeof равным нулю. Значит элементами класса их не сделать бесплатно. В итоге приходилось использовать Empty Base Optimization, когда наследование от класса с нулевым размером оптимизируется в void.
Чтобы это как-то унифицировать, в libc++ сделали compressed_pair<A, B>, чтобы можно было писать члены класса и зафиксировать ABI. Делали A каким-то нужным полем, а B, например, аллокатором, тем самым sizeof сохранялся.

В C++20 добавили атрибут [[no_unique_address]], который запрещает адресоваться к структурам размера ноль, а если более точно, то при попытке так сделать даст какой-то адрес какого-то члена класса.

Спустя 4 года завезли в libc++ и заменили compressed_pair. Патч тащили 9 месяцев, потому что поломалось всё в дебагерах. Дотащили, дебаг символы в хромиум уменьшились на 5%, компиляция ускорилась на 1-1.5%, что не может не радовать.

https://github.com/llvm/llvm-project/pull/76756

BY Experimental chill


Warning: Undefined variable $i in /var/www/group-telegram/post.php on line 260

Share with your friend now:
group-telegram.com/experimentalchill/283

View MORE
Open in Telegram


Telegram | DID YOU KNOW?

Date: |

Telegram users are able to send files of any type up to 2GB each and access them from any device, with no limit on cloud storage, which has made downloading files more popular on the platform. Given the pro-privacy stance of the platform, it’s taken as a given that it’ll be used for a number of reasons, not all of them good. And Telegram has been attached to a fair few scandals related to terrorism, sexual exploitation and crime. Back in 2015, Vox described Telegram as “ISIS’ app of choice,” saying that the platform’s real use is the ability to use channels to distribute material to large groups at once. Telegram has acted to remove public channels affiliated with terrorism, but Pavel Durov reiterated that he had no business snooping on private conversations. Emerson Brooking, a disinformation expert at the Atlantic Council's Digital Forensic Research Lab, said: "Back in the Wild West period of content moderation, like 2014 or 2015, maybe they could have gotten away with it, but it stands in marked contrast with how other companies run themselves today." During the operations, Sebi officials seized various records and documents, including 34 mobile phones, six laptops, four desktops, four tablets, two hard drive disks and one pen drive from the custody of these persons. The perpetrators use various names to carry out the investment scams. They may also impersonate or clone licensed capital market intermediaries by using the names, logos, credentials, websites and other details of the legitimate entities to promote the illegal schemes.
from id


Telegram Experimental chill
FROM American