Re: map<int, float>::iterator

From: Arthur E. Snyder <snyder_at_slac.stanford.edu>
Date: Sun, 14 Dec 2008 23:24:04 -0800


Have you tried compiling code instead of using the intreptation?

.L mycode.C+ or .L mycode.C++

I have found previously that not all legal C++ code works in cint.

-Art S.

A.E. Snyder, Group EC                        \!c*p?/
SLAC Mail Stop #95                          ((.   .))
Box 4349                                        |
Stanford, Ca, USA, 94309                      '\|/`
e-mail:snyder_at_slac.stanford.edu                 o
phone:650-926-2701                              _
http://www.slac.stanford.edu/~snyder          BaBar
FAX:650-926-2657                          Collaboration



On Mon, 15 Dec 2008, Anil Singh wrote:

>
> 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,
>
> =============================
> std::map<int, float>::iterator flt;
> =============================
>
> this declaration gives an error:
>
> ----------------------------------------------------------------------------------------------
> Symbol iteratorflt is not defined in current scope (tmpfile) (1)
> ***Interpreter error recovererd***
> ------------------------------------------------------------------------------------------------
>
> 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
>
>
>
>
>
>
>
>
> ----- Original Message -----
> From: Christopher Jones <c_jones_at_MIT.EDU>
> Date: Sunday, December 14, 2008 6:47 pm
> Subject: Re: [ROOT] map<int, float>::iterator
> To: Anil Singh <anil79_at_fnal.gov>
> Cc: roottalk_at_cern.ch
>
>
>> 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 - 08:24:15 CET

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