Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-02-08 09:48:52

one of program_options' iterators no longer work on borland 5.6.4.

The iterator is defined like:

  class environment_iterator
        : public eof_iterator<environment_iterator,
                              std::pair<std::string, std::string> >

Where eof_iterator is define like this:

  template<class Derived, class ValueType>
    class eof_iterator : public iterator_facade<Derived, const ValueType,

So, the ValueType passed to iterator_facade is const std::pair<string,
string>. The error produced by Borland is:

Error E2034
Cannot convert 'const pair<string,string> *' to 'pair<string,string> *' in
function operator_arrow_result<pair<string,string>,const pair<string,string>
&,pair<string,string> *>::make(const pair<string,string> &)
Error E2342
Type mismatch in parameter 'x' (wanted 'pair<string,string> *', got 'const
pair<string,string> *') in function
operator_arrow_result<pair<string,string>,const pair<string,string>
&,pair<string,string> *>::make(const pair<string,string> &)

It happens when instantiating this class.

 template <class ValueType, class Reference, class Pointer>
    struct operator_arrow_result

On borland, non-const type is passed as Pointer, which leads to the problem.
Looks like the logic which computes the ::reference type confuses borland. On
gcc, const type is passed as Pointer. The attached patch fixes the problem,
by replacing



   const value_type

I haven't used #ifdef, because I think that the change should work on other
compilers, too. At least it does not break any iterator tests with gcc.

- Volodya

Boost list run by bdawes at, gregod at, cpdaniel at, john at