class test_string
{
struct _Rep_base
{
int* _M_length;
int* _M_capacity;
int* _M_refcount;
};
struct _Alloc_hider
{
int* _M_p; // The actual data.
};
mutable _Alloc_hider _M_dataplus;
_Rep_base t;
};
void test()
{
cout<<sizeof(string)<<endl;
string s("adfaf");
cout<<sizeof(s)<<endl;
cout<<sizeof(test_string)<<endl;
}
抽取了部分5.1版本下basic_string.h下的源码,测得以上size均为32B