Re: map<int, float>::iterator

From: Christopher Jones <c_jones_at_MIT.EDU>
Date: Mon, 15 Dec 2008 03:09:40 -0500


>
> Have you tried compiling code instead of using the intreptation?

I concur; I did my workaround by just compiling code against the ROOT libraries that I needed using g++. That way I can use map iterators and vectors of pairs to my heart's content.

As Arthur said, CINT's support of the STL isn't perfect. I can instantiate map<int, float>s just fine, so it probably depends on which version you're using (I'm using 5.21/04 trunk_at_25661). If you want to add functionality, it's been documented how to do this:

http://root.cern.ch/root/RootCintMan.html

You'll need to modify the #pragmas and use ROOTCINT.

On Dec 15, 2008, at 2:24 AM, Arthur E. Snyder wrote:
>
>
> .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
>>>
>>>
>>>
>>>
>>>
>>
>>

Chris Jones
c_jones_at_mit.edu Received on Mon Dec 15 2008 - 09:09:50 CET

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