Boost logo

Boost :

From: MB (mb2act_at_[hidden])
Date: 2005-12-31 22:41:31


Eric Niebler wrote:
> There is a bug in Boost.Range that is causing boost::end() to execute a
> slower code path when called with a string literal. The type of "hello"
> is char const [6], and end() should be O(1). Indeed, Boost.Range has
> code to handle just this case, but it never gets called. The problem is
> the way overload resolution happens between these two functions
>
> 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.
>

I guess that is intentional.
See: boost::end("hello\0secret")

BTW, '#define foreach BOOST_FOREACH' causes name conflict with Boost.Foreach. :-)

Regards,
MB
p-stade.sourceforge.net


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