Hi,
It seems that root does not allow us to define a pointer/ iterator to map<int, float> object. If we do following on interactive root mode:
#include<map>
std::map<int, int>::iterator iter;
The declaration is accepted without a complaint. On the other hand,
this declaration gives an error:
I also had a problem similar to your's when it tried to define a function like:
void AddEntryToMap( std::map<int, float>& Map) {
Map[0] =1;
Map[1] =3.2;
}
this function when called shot an error, which I can remember at the moment...I will send a follow up mail soon.....about it.
Anil
> By "not work" do you mean that when you try to dereference the
> map<int, float> iterator, you get an error? Could you paste your error?
>
> I have no problem using map<int, int>s either, but:
>
> >map<int, float> map1;
> >map1[3] = 4.32; // test values
> >map1[4] = 5.67;
> >map<int, float>::iterator it = map1.begin();
>
> >*it; // same error if you try it->first or it->second
> Error: Illegal pointer operation (tovalue) (tmpfile):1:
> (const class map<int,float,less<int>,allocator<pair<const int,float> >
>
> >::iterator)0
> *** Interpreter error recovered ***
>
> I have the same problem making std::vectors of pair< int, float >,
> even though I can define pairs and access them just fine. I think
> ROOT has trouble dealing with maps because it can't handle collections
>
> of pairs (and I think maps are handled as pairs).
>
> On Dec 14, 2008, at 7:08 PM, Anil Singh wrote:
>
> > Hi All,
> >
> > I am working with a code that reqire extensive use of
> > std::map objects . I was trying to do something like :
> > //--------------------------
> > {
> > #include<map>
> > using namespace std;
> > std::map<int, int>::iterator int_iter;
> > std::map<int, float>::iterator flt_iter;
> > }
> > //----------------------------
> >
> > It seems that though "std::map<int, int>::iterator" is
> > fine but
> > "std::map<int, float>::iterator", does not work at all......
> > Any help is appreciated.
> > Anil Singh
> > FermiLab
> >
>
> Chris Jones
> c_jones_at_mit.edu
>
>
>
>
>
Received on Mon Dec 15 2008 - 07:49:21 CET
This archive was generated by hypermail 2.2.0 : Mon Dec 15 2008 - 11:50:02 CET