• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
C++ code compiles with libstdc++ but not libc++
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C++ code compiles with libstdc++ but not libc++


  • Subject: C++ code compiles with libstdc++ but not libc++
  • From: Jean-Denis MUYS <email@hidden>
  • Date: Tue, 02 Oct 2012 15:48:49 +0000
  • Thread-topic: C++ code compiles with libstdc++ but not libc++

Hi,

I am working on a rather large C++ library that has been ported to iOS some time ago against GCC and libstd++. I want to migrate it to LLVM 4.1 and libc++.

I am currently failing on the "!=" operator on the second line there:

            for(KVector<HWND>::iterator iterColHwndLog = colHwndLog.begin()
               ;iterColHwndLog != colHwndLog.end()
               ;++iterColHwndLog
               )


The error message is:

Use of overloaded operator '!=' is ambiguous (with operand types 'KVector<HWND>::iterator' (aka '__wrap_iter<pointer>') and 'iterator' (aka '__wrap_iter<pointer>'))

Note the "aka"'s are the same and the actual type differ only by their scope.

Note also that this same code compiles just fine with the same compiler (LLVM 4.1) but choosing libstc++ as the target's standard C++ library setting.

Past history has shown that the library is usually wrong when disagreeing with Clang. However, here Clang doesn't see a problem with the GNU version of the standard library. Unfortunately, my C++ template-fu is not first class, and I don't quite know what I can do to investigate this.

Any idea?

KVector is defined thus:

using namespace std;
class KVector : public vector<T> { … }

and I found this definition for operator !=:

template< class T >
inline bool
operator!=( const T& x, const T& y )
{
    return !( x == y );
}

I can provide more detail, but I am not sure what would be relevant.

Could it be a bug in libc++?

Thanks,

Jean-Denis



PS: here is the full class declaration for KVector:

template<class T>
class KVector : public vector<T>
{
public:
    bool IsNull() const {return(vector<T>::size() == 0);};
    void SetNull() {vector<T>::clear();};
    typename vector<T>::iterator erase(int row)
    {
        if((row < 0) || ((size_t)row >= vector<T>::size()))
        {
            return(vector<T>::end());
        }
        return(vector<T>::erase(vector<T>::begin() + row));
    }
    typename vector<T>::iterator erase(size_t row)
    {
        if(row >= vector<T>::size())
        {
            return(vector<T>::end());
        }
        return(vector<T>::erase(vector<T>::begin() + row));
    }
    typename vector<T>::iterator erase(typename vector<T>::const_iterator it)
    {
        return(vector<T>::erase(it));
    }
    typename vector<T>::iterator erase(T* ptr)
    {
        typename vector<T>::const_iterator it = const_iterator(ptr, this);
        return(vector<T>::erase(it));
    }
    void erase()
    {
        vector<T>::clear();
    }
    typename vector<T>::iterator insert(int row, const T& val)
    {
        return(vector<T>::insert(vector<T>::begin() + row, val));
    }
    typename vector<T>::iterator insert(size_t row, const T& val)
    {
        return(vector<T>::insert(vector<T>::begin() + row, val));
    }
    typename vector<T>::iterator insert(typename vector<T>::const_iterator pos, const T& val)
    {
        return(vector<T>::insert(pos, val));
    }
    typename vector<T>::iterator insert(T* ptr, const T& val)
    {
        typename vector<T>::const_iterator pos = const_iterator(ptr, this);
        return(vector<T>::insert(pos, val));
    }
    void insert(typename vector<T>::const_iterator pos, typename vector<T>::size_type n, const T& val)
    {
        return(vector<T>::insert(pos, n, val));
    }
    void insert(T* ptr, typename vector<T>::size_type n, const T& val)
    {
        typename vector<T>::const_iterator it = const_iterator(ptr, this);
        return(vector<T>::insert(it, n, val));
    }
    void Inflate(size_t maxIndex)
    {
        if(maxIndex > vector<T>::size()) insert(vector<T>::end(), maxIndex - vector<T>::size(), T());
    };
};









Logo Kleegroup
Klee Group is a great place to work – Il fait bon travailler à Klee Group
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: C++ code compiles with libstdc++ but not libc++
      • From: Jean-Denis MUYS <email@hidden>
  • Prev by Date: Re: Adding Buttons without Unembedding
  • Next by Date: Re: C++ code compiles with libstdc++ but not libc++
  • Previous by thread: Re: Adding Buttons without Unembedding
  • Next by thread: Re: C++ code compiles with libstdc++ but not libc++
  • Index(es):
    • Date
    • Thread