[ create a new paste ] login | about

Link: http://codepad.org/2M7N9cTu    [ raw code | output | fork ]

ArtemGr - C++, pasted on May 24:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Size of SSO string:
// http://gcc.gnu.org/onlinedocs/gcc-4.6.3/libstdc++/api/a01035_source.html
// http://stackoverflow.com/questions/5419016/string-class-allocating-on-stack-for-small-strings

#include <iostream>
using namespace std;

struct sso_string {
  enum { _S_local_capacity = 15 };
  union {
    char _M_local_data[_S_local_capacity + 1];
    unsigned _M_allocated_capacity;
  };
};

int main () {
  cout << sizeof (sso_string) << endl;
  return 0;
}


Output:
1
16


Create a new paste based on this one


Comments: