
9 Feb
2009
9 Feb
'09
6:39 p.m.
Chris Hamilton wrote:
The reason I want this, is to have a nice String variant, that encapsulates the various forms a string can take in a current project: std::strings, char*'s, and std::string* and boost::shared_ptr<std::string>. I want functions to be able to handle all of these types transparently by using variants as the argument types. Allowing "const std::string&" as a variant type allows this to be done while not requiring a wasteful string copy.
Why can't you simply use std::pair<const char*, size_t>? That seems to cover all possibilities already... (assuming std::string is contiguous, which is true in the real world).