Boost logo

Boost :

From: Pavol Droba (droba_at_[hidden])
Date: 2003-01-08 08:50:08


Hi Boosters,

I'd like to hear your opinion about following issue:

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 )
    {
                ...
    }

They are two variants of the same algorithm. Difference is that
one variant works on const input while the other one is mutable.
Difference is also in the return value. One version contains a
const_iterator, while the other one a mutable iterator.

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.

Unfortunately not all compilers can hadle this well. For instance
VC7 can't handle it properly.

A possible workaround is to rename on of the variants.
I have added _mutable suffix to the non-const version.

My question is, if it is reasonable to do such a rename for all
platforms, or it is better to use a macro and add the suffix only for
broken platforms?

Thanks for help.

Pavol


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