I <3 being able to use aggregate initialization, the C++20 feature that we explicitly allow now. I'm trying to use it to clean up structs, and in particular
content::DropData::Metadata which has all these CreateFor* calls that just shove values into member variables. I'd like to replace:
if (drop_data.html) {
metadata.push_back(DropData::Metadata::CreateForMimeType(
DropData::Kind::STRING, base::ASCIIToUTF16(ui::kMimeTypeHTML)));
}
with
if (drop_data.html) {
metadata.push_back(
DropData::Metadata{.kind = DropData::Kind::STRING,
.mime_type = base::ASCIIToUTF16(ui::kMimeTypeHTML)});
}
But that struct is just too big and lives in a header, so it needs to have an explicit out-of-line constructor/destructor/copy constructor. Which, even if defaulted, is a user-defined constructor, which means that aggregate initialization isn't allowed.
I vaguely recall discussions about whether that was still a useful plugin check. I submit this as evidence of its interaction with new language features.
Avi