std::string == operator not working

Posted by Paul on Stack Overflow See other posts from Stack Overflow or by Paul
Published on 2010-05-11T15:47:25Z Indexed on 2010/05/11 15:54 UTC
Read the original article Hit count: 331

Filed under:
|
|

Hello,

I've been using std::string's == operator for years on windows and linux. Now I am compiling one of my libraries on linux, it uses == heavily. On linux the following function fails, because the == returns false even when the strings are equal (case sensitive wise equal)

const Data* DataBase::getDataByName( const std::string& name ) const
{
         for ( unsigned int i = 0 ; i < m_dataList.getNum() ; i++ )
         {
                if (  m_dataList.get(i)->getName() == name )
                {
                         return  m_dataList.get(i);
                }
         }

         return NULL;
}

The getName() method is declared as follows

virtual const std::string& getName() const;

I am building with gcc 4.4.1 and libstdc++44-4.4.1.

Any ideas? it looks perfectly valid to me.

Paul

© Stack Overflow or respective owner

Related posts about c++

Related posts about string