# Vector\< pair\<\> \>

**URL:** <https://root-forum.cern.ch/t/vector-pair/11896>\
**Category:** ROOT\
**Created:** [February 18, 2011, 3:38pm UTC](https://root-forum.cern.ch/t/vector-pair/11896 "2011-02-18T15:38:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhisek](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/c5a1d2/32.png) [@abhisek](https://root-forum.cern.ch/u/abhisek)\
**Post date:** [February 18, 2011, 3:38pm UTC](https://root-forum.cern.ch/t/vector-pair/11896/1 "2011-02-18T15:38:40Z")

</div>

Hi all,  
Could someone please explain why the below code is not working with root? It works perfectly with g++(just remove all // ) . I know it has to do with **CINT**. Can someone please guide me to a solution?  
Thanks in advance…

Abhisek

// macro [test.cc](http://test.cc)  
//#include \<stdio.h\>  
#include   
#include  
//using namespace std;

//int main(void) //  
void test()  
{  
vector\< pair\<int,double\> \> my\_data;

for(int i=1; i\<10; i++)  
{  
my\_data.push\_back( make\_pair( i, (double)i+2.2 ) );  
}  
//cout \<\< my\_data[1]-\>second\<\< endl;

for( vector\< pair\<int,double\> \>::iterator iter= my\_data.begin(); iter!=my\_data.end(); iter++)  
{  
cout \<\< iter-\>first \<\< " " \<\< iter-\>second \<\< endl;  
}

}

---

<div class="post-metadata">

**Author:** ![karolos](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/karolos/32/12826_2.png) [@karolos](https://root-forum.cern.ch/u/karolos)\
**Post date:** [March 2, 2011, 8:18am UTC](https://root-forum.cern.ch/t/vector-pair/11896/2 "2011-03-02T08:18:00Z")

</div>

Hi,

You could try running your code as follows:

```auto

```

which will compile your code before executing it (so it even runs faster). It works in ROOT v5.28.00.

If the int in your pair\<int,double\> is unique, I’d recommend using map\<int, double\>. If it’s not, you could use multimap\<int, double\>. However if you want to preserve the order (which I assume is the reason why you use a vector) you could use tr1::unordered\_map and tr1::unordered\_multimap. However, I don’t know if this is possible as is in CINT. Perhaps you could try to include gInterpreter-\>AddIncludePath() statements to point to the tr1 header files.

Cheers,  
Karolos

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [March 2, 2011, 8:27am UTC](https://root-forum.cern.ch/t/vector-pair/11896/3 "2011-03-02T08:27:59Z")

</div>

See the post of “Tue Mar 01, 2011 14:24” in this thread: [url][Vectors in 5.28.00](https://root-forum.cern.ch/t/vectors-in-5-28-00/11846/1)

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [March 2, 2011, 10:47am UTC](https://root-forum.cern.ch/t/vector-pair/11896/4 "2011-03-02T10:47:41Z")

</div>

Thanks, Pepe. I’ll post the good news also here: it’s fixed! Thanks for your report, Abhisek!

Cheers, Axel.
