https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87619

            Bug ID: 87619
           Summary: sizeof(std::variant) can be reduced if its
                    variant_size is UCHAR_MAX
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kariya_mitsuru at hotmail dot com
  Target Milestone: ---

The current implementation of std::variant stores its index() on an unsigned
char member variable (_M_index) if its std::variant_size is less than
UCHAR_MAX.

But I think that its index() can be stored on unsigned char even if its
variant_size is equal to UCHAR_MAX.

cf. https://wandbox.org/permlink/CpVcCKU3526PnDel


FYI: I think that the first template parameter of _Select_int_base is slightly
larger than necessary.
https://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/include/std/variant?revision=264786&view=markup#l365

Reply via email to