2 Nov
2013
2 Nov
'13
midnight
AMDG On 11/01/2013 04: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" );
I see that adding this directly doesn't work as the compiler is always choosing to decay and pick the const char* overload.
Is there no way to make this work?
The behavior is not guaranteed to be the same, anyway. Not all char arrays are string literals. In Christ, Steven Watanabe