关于gcc中string的sizeof

来源:互联网 发布:淘宝网夏秋棉麻连衣裙 编辑:程序博客网 时间:2024/06/13 17:57
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

0 0
原创粉丝点击