I have map data structure map<string, vector< pair<string, string> >, where map key is of string data type and value is vector<pair<string, string> > data type.
if i try to perform find or count operation using key value which is of string data type. I do get compilation issue.
why is it behaving so? i should have able to perform either find/count operation on map!
basically i have typedef the map data structure as below:-
typedef pair<string,string> attribute_pair;
typedef vector<attribute_pair> attribute_vector;
typedef map<string,attribute_vector> testAttribute_map;
part of the code snippet where trying to perform find operation
testAttribute_map attributes;
string fileName = "Hello.cpp";
if(testAttribute_map iter = attributes.find(fileName))
{
cout<<"success"<<endl;
}
compilation error:
error: conversion from ‘std::map<std::__cxx11::basic_string<char>, std::vector<std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > > >::iterator {aka std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, std::vector<std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > > > >}’ to non-scalar type ‘testAttribute_map {aka std::map<std::__cxx11::basic_string<char>, std::vector<std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > > >}’ requested
Aucun commentaire:
Enregistrer un commentaire