HomePhabricator

[libc++] Shrink variant's index type when possible

Authored by EricWF on Nov 18 2017, 8:19 PM.

Description

[libc++] Shrink variant's index type when possible

Summary:
Currently std::variant always uses an unsigned int to store the variant index. However this isn't nessesary and causes std::variant to be larger than it needs to be in most cases.

This patch changes the index type to be unsigned char when possible, and unsigned short or unsigned int otherwise, depending on the size (Although it's questionable if it's even possible to create a variant with 65535 elements.

Unfortunately this change is an ABI break, and as such is only enabled in ABI v2.

Reviewers: mpark

Reviewed By: mpark

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D40210

llvm-svn: 318621

Details

Committed
EricWFNov 18 2017, 8:19 PM
Reviewer
mpark
Differential Revision
D40210: [libc++] Shrink variant's index type when possible
Parents
rGfc1b8b12c7cc: [X86] Make sure 'knm' is accepted by -target-cpu
Branches
Unknown
Tags
Unknown