3 Nov
2013
3 Nov
'13
3:56 a.m.
On 11/2/2013 9:43 AM, Marshall Clow wrote:
On Nov 1, 2013, at 4:42 PM, Michael Marcin
wrote: I noticed string_ref doesn't have a constructor for a string literal. Wouldn't this save a call to strlen for a common case?
Ex.
template< std::size_t N > basic_string_ref( const charT( &str )[N] ) : basic_string_ref( str, N-1 ) { static_assert(N >= 1, "not a string literal"); }
string_ref test( "test" );
So, what should string_ref ( "test\0test" ) do?
{ ptr, 4 } --> current behavior { ptr, 9 } --> your suggested behavior
So, what should const char s[] = {'0', '1', '2'}; string_ref test{s}; do? Neither seems to be very important and can be handled by requiring sane preconditions.