$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-01-08 11:24:51
>From: "Vladimir Prus" <ghost_at_[hidden]>
> Pavol Droba wrote:
>
> > I have following two variants of the same function:
> >
> > // find_first sequence const version
> > template< typename InputT, typename SearchT >
> > inline iterator_range< typename InputT::const_iterator >
> > find_first( const InputT& Input, const SearchT& Search )
> > {
> > ...
> > }
> >
> > // find_first sequence non-const version
> > template< typename InputT, typename SearchT >
> > inline iterator_range< typename InputT::iterator >
> > find_first( InputT& Input, const SearchT& Search )
> > {
> > ...
> > }
> >
> > According to C++ standard it is perfectly legal to have these
> > two variants and feature known as "function template ordering"
> > does the job of choosing the right variant according to an input.
>
> Strictly speaking, I believe that's overload resolution which selects
> the right one.
Well, in the case of function templates, partial ordering of function
templates may be used to determine which overloaded template to use, so both
are right. :) In this case, the first template is more specialised than the
second (due to the const).
Regards,
Terje