This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/51453] New: Feature request: Implement Empty Base Optimization in std::tuple


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51453

             Bug #: 51453
           Summary: Feature request: Implement Empty Base Optimization in
                    std::tuple
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: nasos_i@hotmail.com


Is it possible to implement empty base optimization on std::tuple, so that
tuples with member free elements have no memory footprint?


struct _Tuple_impl<_Idx>
    { 
    ...
    protected:
      short dummy[0]; // NEW
      void _M_swap_impl(_Tuple_impl&) { /* no-op */ }
    };


simple test:

#include <tuple>
...
    class empty { short d[0]; };
    std::tuple<empty, empty, empty> a;
    std::cout << sizeof(a) << std::endl; // 2 without tuple ebo (current), and
0 with tuple ebo
...

Best,
Nasos


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]