News Score: Score the News, Sort the News, Rewrite the Headlines

An informal comparison of the three major implementations of std::string - The Old New Thing

May 10th, 2024 We saw some time ago that the three major implementations of std::string are all quite different. To summarize: // gcc struct string { char* ptr; size_t size; union { size_t capacity; char buf[16]; }; bool is_large() { return ptr != buf; } auto data() { return ptr; } auto size() { return size; } auto capacity() { return is_large() ? capacity : 15; } }; // msvc struct string { union { char* ptr; char buf[16]; }; size_t size; size_t capacity; bool is_large() { return capacity > 15;...

Read more at devblogs.microsoft.com

© News Score  score the news, sort the news, rewrite the headlines