Domanda

I have a map which maps a pair of two classes to a simple string. "FirstCollection" and "SecondCollection" are classes, "myCollecttion" is an object of one of them. But when iterating over the map I'm getting a compile error:

error: no match for call to '(const std::basic_string) ()'

typedef std::map <
    std::pair < Collection, Envelope::Envelope >
  , std::string > NameMap;

NameMap globalNameMap = map_list_of
        ( std::make_pair ( FirstCollection, Envelope::A ), "Something")
        ( std::make_pair ( SecondCollection, Envelope::B ), "Another thing")


    NameMap::const_iterator iter
            = globalNameMap.find( std::make_pair ( myCollection, myEnvelope ));

    if ( iter == globalNameMap.end() )
    {
          parent->setName("anything");
    } else {
          parent->setName(iter->second());
    }

Error in this line: parent->setName(iter->second());

Any suggestions?

È stato utile?

Soluzione

iter->second is a member variable not a function. Remove the parentheses: parent->setName(iter->second);.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top