
On Dec 10, 2012, at 4:16 PM, Jeffrey Yasskin <jyasskin@googlers.com> wrote:
On Wed, Nov 28, 2012 at 2:48 AM, Rob Stewart <robertstewart@comcast.net> wrote:
o char const (&)[N]
This constructor is dangerous in cases like
char space[100]; snprintf(space, 100, "format", args); string_ref str(space);
so I think most of the suggestions on this list have moved toward a more explicit but very verbose string_ref::from_literal("foo\0bar").
Misuse is the user's fault, of course, but I understand the value of enlisting the compiler's help and making things verbose to turn mistakes into errors or to make them more obvious. In your example, from_literal() is incorrect as the construction should be from a char * (after array to pointer decay), with an implicit strlen(), not from a string literal. So, I think you meant that from_array() should replace the referenced constructor so string_ref(char const *) matches the call in your example instead. That's a reasonable change. ___ Rob