//Purpose: // Explore how to minimize space taken by struct of // optionals. //Reference: // // http://article.gmane.org/gmane.comp.lib.boost.devel/209212 // #include #include struct A { int a; double b; double c; std::string d; }; struct B { boost::optional< int > a; boost::optional< double > b; boost::optional< double > c; boost::optional< std::string > d; }; struct A_pairs { int a; bool ta; double b; bool tb; double c; bool tc; std::string d; bool td; }; struct A_bools { int a; double b; double c; std::string d; bool ta; bool tb; bool tc; bool td; }; struct bools_A { bool ta; bool tb; bool tc; bool td; int a; double b; double c; std::string d; }; struct chars_A { char ta; char tb; char tc; char td; int a; double b; double c; std::string d; }; int main(void) { std::cout<<"sizeof(A)="<