[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost
Subject:    Re: [boost] [range] boost::end("hello") is sub-optimal
From:       "Maxim Yegorushkin" <maxim.yegorushkin () gmail ! com>
Date:       2005-12-31 20:15:44
Message-ID: op.s2nzwis9p2vbb7 () home
[Download RAW message or body]

On Sat, 31 Dec 2005 09:15:39 +0300, Eric Niebler <eric@boost-consulting.com> wrote:

[]

>     template< typename T, std::size_t sz >
>     const T* boost_range_end( const T (&array)[sz] )
>
>     const char* boost_range_end( const char* s )
>
> The first is O(1) and the second is O(N) becuase it calls strlen. But
> the second will always be chosen because non-templates are preferred
> over templates.

It depends on a compiler. gcc replaces strlen() calls with a constant when called with a string literal.



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic