|
Boost : |
From: Beman Dawes (bdawes_at_[hidden])
Date: 2003-10-23 10:16:09
At 10:47 AM 10/23/2003, Pavol Droba wrote:
>On Thu, Oct 23, 2003 at 11:28:38PM +1000, Thorsten Ottosen wrote:
>> I would say we have to provide
>>
>> template<typename InputContainerT, typename SearchContainerT>
>> iterator_range< typename string_algo::container_const_iterator<
>> InputContainerT >::type >
>> find_first(const InputContainerT &, const SearchContainerT &);
>>...
>
>Yes you have overlooked one important point. Your second proposed variant
>does not make sense and what worse, it is even very dangerous.
>
>find_xxx algorithms return a reference into the input container by the
>means
>of iterators. Using a temporary as an input, you would get an invalid
>reference as a result.
>
>Returning a reference from a temporary is quite a big error in my
opinion.
What is the fix? There really needs to be some convenient way to do a
find_first on a const container. Provide a version that takes begin and end
iterators? Or is that already done by one of the algorithms in detail that
you are going to move into boost::algorithm::string?
Something really seems wrong here. If container oriented non-mutating
algorithm functions like find_first can't be used with const container
arguments, they may be seen as greatly inferior to the traditional iterator
oriented non-mutating algorithm functions, which work fine with const
containers.
--Beman
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk