|
Boost : |
From: Maxim Yegorushkin (maxim.yegorushkin_at_[hidden])
Date: 2005-12-31 15:15:44
On Sat, 31 Dec 2005 09:15:39 +0300, Eric Niebler <eric_at_[hidden]> 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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk