Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 2. vector and string > Item 15: Be aware of variations in string implem...

Item 15: Be aware of variations in string implementations

Bjarne Stroustrup once wrote an article with the curious title, “Sixteen Ways to Stack a Cat” [27]. It turns out that there are almost as many ways to implement strings. As experienced and sophisticated software engineers, of course, we’re supposed to pooh-pooh “implementation details,” but if Einstein is right and God is in the details, reality requires that we sometimes get religion. Even when the details don’t matter, having some idea about them puts us in a position to be sure they don’t matter.

For example, what is the size of a string object? In other words, what value does sizeof(string) return? This could be an important question if you’re keeping a close eye on memory consumption, and you’re thinking of replacing a raw char* pointer with a string object.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial