-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathSSO.cpp
More file actions
22 lines (18 loc) · 910 Bytes
/
SSO.cpp
File metadata and controls
22 lines (18 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// =====================================================================================
// SSO.cpp // SSO (Small String Optimization)
// =====================================================================================
module modern_cpp:sso;
void main_sso()
{
auto size{ sizeof(std::string) };
auto capacity{ std::string{}.capacity() };
auto small { std::string(capacity, '*') };
auto big{ std::string(capacity + 1, '#') };
std::cout << "sizeof : " << size << std::endl;
std::cout << "Capacity: " << capacity << std::endl;
std::cout << "Small : " << small.capacity() << ": " << small << std::endl;
std::cout << "Big : " << big.capacity() << ": " << big << std::endl;
}
// =====================================================================================
// End-of-File
// =====================================================================================