Boost logo

Boost :

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


Hello,
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,
                                                forward_traversal_tag>

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

Error E2034
C:\Users\Administrator\boost\main\boost\boost/iterator/iterator_facade.hpp
326:
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
C:\Users\Administrator\boost\main\boost\boost/iterator/iterator_facade.hpp
326:
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

   add_const<value_type>::type

with

   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.
Comments?

- Volodya




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