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: [email protected]
ReportedBy: [email protected]
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