Re: map<int, float>::iterator

From: Christopher Jones <c_jones_at_MIT.EDU>
Date: Sun, 14 Dec 2008 19:38:10 -0500


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 - 01:47:42 CET

This archive was generated by hypermail 2.2.0 : Mon Dec 15 2008 - 11:50:02 CET