Gå til innhold

std::map og itereringer


Anbefalte innlegg

typedef std::pair<std::string, int> AdminDetailPair;
typedef std::map<std::string, AdminDetailPair > AdminMap;

AdminMap admins;

void CBotAdmin::saveAdmins() {
std::fstream fp;
AdminMap::const_iterator its;

fp.open(adminFile.c_str(), std::ios::out);
if(fp.is_open()) {
 its = admins.begin();
 while(its < admins.end()) {
 	fp << its->first << ":" << its->second.second << ":" << its->second.first << std::endl;
 	++its;
 }
}
fp.close();
}

Første error fra msvs er:

error C2784: 'bool std::operator <(const std::vector<_Ty,_Alloc> &,const std::vector<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'std::map<_Kty,_Ty>::const_iterator'

        with

        [

            _Kty=std::string,

            _Ty=CBotAdmin::AdminDetailPair

        ]

 

Noen som kan hjelpe? :roll:

 

 

 

[EDIT:]

Msvs sier dette om error C2784

'declaration' : could not deduce template argument for 'type' from 'type'

 

The compiler cannot determine a template argument from the supplied function arguments.

 

Example

 

// C2784.cpp

template<class T> class X

{

};

 

template<class T> void f(X<T>)

{

}

int main()

{

  f(1); // C2784

  // try the following lines instead

  // X<int> x;

  // f(x);

}

Endret av Nazgul
Lenke til kommentar
Videoannonse
Annonse

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...