String Length

Most of the discussion in the article has centered on the generalization of access to the string contents. However, length is an important attribute of all strings, and one that, with the exception of C-style strings, is usually already calculated. It would be useful to be able to have a generalized approach to the determination of length that would efficiently use the available attribute where it exists rather than calculating it each time.

Each c_str_ptr() access shim is accompanied by a corresponding c_str_len() attribute shim, some of which are shown in Listing 12.