const XX discards qualifiers [- fpermissive]

Im code-snippet 1 unten, mKnownSRList ist wie folgt definiert:

std::vector<EndPointAddr*> mKnownSRList;

Ich bin immer ein Kompilierungsfehler angezeigt, die im code-snippet 2. Können Sie mir sagen, was ist falsch an diesem code bitte? Die Inhalte der getTipcAddress() und compareTo-Funktionen sind dargestellt in der code-snippet 3 und 4 unten.

CODE-SNIPPET 1 (Kompilierung Fehler ist markiert)

void 
ServiceRegistrarAPI::removeKnownSR(EndPointAddr & srEndPointAddr)
{
   auto last = 
   std::remove_if(mKnownSRList.begin(),
                  mKnownSRList.end(),
                 [srEndPointAddr]( EndPointAddr* o )
                 { 
                    //LINE 355 is the following
            EndPointTipcAddr myTipcAddress = srEndPointAddr.getTipcAddress();
                EndPointTipcAddr otherTipcAddress = o->getTipcAddress();

            return (myTipcAddress.compareTo(otherTipcAddress));
         });

    if(*last != nullptr)
    {
     delete *last;
    }

    mKnownSRList.erase(last, mKnownSRList.end());    
}

SNIPPET 2 (Kompilierungsfehler)

  ServiceRegistrarAPI.cpp:355:72: error: passing const EndPointAddr as this   argument of EndPointTipcAddr& EndPointAddr::getTipcAddress()’ discards qualifiers [-  fpermissive]

CODE-SNIPPET 3 (getTipcAddress Funktion)

EndPointTipcAddr & getTipcAddress() { return mTipcAddress; }

CODE NIPPET 4 (compareTo-Funktion)

  bool

  EndPointTipcAddr::compareTo(EndPointTipcAddr &rhs) 
  {     
      if( (mType == rhs.getType()) && (mInstanceNo == rhs.getInstanceNo()) )
      {
        return true;
      } 

      return false;
  }
InformationsquelleAutor F. Aydemir | 2013-03-25
Schreibe einen Kommentar