As already mentioned in the comment, the functions and orders of functions is not important for the size.
There really should not be any padding in the MyClass structure itself (or at least not on a 32bit system, but you are not mentioning the cpu architecture), however the content of the std::vector and std::string is allocated outside the actual structure of the class.
As you can see in this answer the content of the vector is in contiguous memory allocated as you are adding data into the vector, and unless you are setting the capacity there may be a lot of overhead -- so the capacity()
of the std::vector data within MyClass may add additional overhead.
The only structure where elimination of padding could save you anything would be in the std::pair<char, MyClass>
.. you are not saying anything about how many element you are having in the std::vector, but if almost one for every possible char (i.e. almost 256), and since you are concerned about total memory consumption, then you may be better off using a
MyClass *fils[256];
instead of
std:vector< std:pair<char, MyClass> > fils
as you no longer will need to manage the capacity of the vector to get the exact space, and you have about the same amount of overhead as the std::pair when padded.
Also, the overhead of an empty std::string on my system is 32 bytes, so depending on what you are keeping in etiquette
you may want to reconsider that as well -- for example if the etiquette
in different instances of MyClass is duplicated, you may want to find a way of keeping a unique set of values and just a pointer from MyClass to the unique etiquette
YMMV.