Boost logo

Boost :

Subject: Re: [boost] [string_ref] string literal constructor
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2013-11-02 10:43:40


On Nov 1, 2013, at 4:42 PM, Michael Marcin <mike.marcin_at_[hidden]> 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

-- Marshall

Marshall Clow Idio Software <mailto:mclow.lists_at_[hidden]>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
        -- Yu Suzuki


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk