# Vector\<vector\<int\> \> \*test problem

**URL:** <https://root-forum.cern.ch/t/vector-vector-int-test-problem/15857>\
**Category:** ROOT\
**Created:** [March 29, 2013, 12:21am UTC](https://root-forum.cern.ch/t/vector-vector-int-test-problem/15857 "2013-03-29T00:21:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbouffar](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@jbouffar](https://root-forum.cern.ch/u/jbouffar)\
**Post date:** [March 29, 2013, 12:21am UTC](https://root-forum.cern.ch/t/vector-vector-int-test-problem/15857/1 "2013-03-29T00:21:37Z")

</div>

Hello,

I have had problems with 2D vectors before, but I can’t seem to get this code running.

I have a tree that contains a vector\<vector \> \* variable and I try to access it as follows in a .C script:

[code]vector\<vector \> \*mc\_child\_index;  
t\_in-\>SetBranchAddress(“mc\_child\_index”, &mc\_child\_index);

cout \<\< (mc\_child\_index-\>at(0)).at(0) \<\< endl;  
[/code]

However I get the error:

Error: Can’t call vector\<vector\<int,allocator \>,allocator\<vector\<int,allocator \> \> \>::at(0) in current scope MakeEventShapes.C:829:  
Possible candidates are…  
(in vector\<vector\<int,allocator \>,allocator\<vector\<int,allocator \> \> \>)  
Error: non class,struct,union object $(mc\_child\_index-\>at(0)) used with . or -\> MakeEventShapes.C:829:  
(class G\_\_CINT\_ENDL)342510752  
\*\*\* Interpreter error recovered \*\*\*

I have tried

```auto

```

`if (!(gInterpreter->IsLoaded("vector"))){
  gInterpreter->ProcessLine("#include <vector>");
  gSystem->Exec("rm -f AutoDict*vector*vector*int*");
  gInterpreter->GenerateDictionary("vector<vector<int> >", "vector");
}`

```auto

```

with Loader.C as:

`#include<vector>
#ifdef __CINT__
#pragma link C++ class vector<vector<int> >;
#else
template class std::vector<std::vector<int> >;
#endif
`

Currently using 5.34.05 x86\_64

Anyone know why this isn’t working? Thanks,

-Julian

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [March 29, 2013, 4:23am UTC](https://root-forum.cern.ch/t/vector-vector-int-test-problem/15857/2 "2013-03-29T04:23:31Z")

</div>

Try:  
std::vector\<std::vector \> \*mc\_child\_index = 0; // the pointer MUST be initialized  
// …  
if (mc\_child\_index) std::cout \<\< (mc\_child\_index-\>at(0)).at(0) \<\< std::endl;  
else std::cout \<\< “mc\_child\_index = 0” \<\< std::endl;

---

<div class="post-metadata">

**Author:** ![jbouffar](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@jbouffar](https://root-forum.cern.ch/u/jbouffar)\
**Post date:** [March 29, 2013, 5:54am UTC](https://root-forum.cern.ch/t/vector-vector-int-test-problem/15857/3 "2013-03-29T05:54:30Z")

</div>

Tried it, I get the same error:

Error: Can’t call vector\<vector\<int,allocator \>,allocator\<vector\<int,allocator \> \> \>::at(0) in current scope MakeEventShapes.C:830:  
Possible candidates are…  
(in vector\<vector\<int,allocator \>,allocator\<vector\<int,allocator \> \> \>)  
Error: non class,struct,union object $(mc\_child\_index-\>at(0)) used with . or -\> MakeEventShapes.C:830:  
(class G\_\_CINT\_ENDL)64216224  
\*\*\* Interpreter error recovered \*\*\*

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [March 29, 2013, 6:33am UTC](https://root-forum.cern.ch/t/vector-vector-int-test-problem/15857/4 "2013-03-29T06:33:08Z")

</div>

Try this example (simply replace all occurrences of “float” with “int”): [url][Storing 2D vector [--\> vector\<vector\<...\> \>] into a TTree](https://root-forum.cern.ch/t/storing-2d-vector-vector-vector-into-a-ttree/14331/2)

---

<div class="post-metadata">

**Author:** ![jbouffar](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/87869e/32.png) [@jbouffar](https://root-forum.cern.ch/u/jbouffar)\
**Post date:** [March 29, 2013, 6:38am UTC](https://root-forum.cern.ch/t/vector-vector-int-test-problem/15857/5 "2013-03-29T06:38:36Z")

</div>

Ugh, I had some AutoDict\_vector\_vector\_int files in my directory, I deleted them and it now works…

Now I have new ones, not sure why the old ones didn’t work…

Thanks for responding though!

-Julian

---

<div class="post-metadata">

**Author:** ![htran](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/f1d935/32.png) [@htran](https://root-forum.cern.ch/u/htran)\
**Post date:** [March 19, 2014, 9:29am UTC](https://root-forum.cern.ch/t/vector-vector-int-test-problem/15857/6 "2014-03-19T09:29:41Z")

</div>

Hello,  
Sorry to bring up this subject again but I had the same problem and I tried all the solutions here, none of them worked.  
I have to read a branch vector\<vector \>\* from a tree. The class to read the tree is generated from MakeSelector. But when running the script I got this error:

Error: Can’t call vector\<vector\<int,allocator \>,allocator\<vector\<int,allocator \> \> \>  
::vector\<vector\<int,allocator \>,allocator\<vector\<int,allocator \> \> \>() in current sc  
ope go.C:14:  
Possible candidates are…  
(in vector\<vector\<int,allocator \>,allocator\<vector\<int,allocator \> \> \>)

Could you provide some suggestion how to fix this?

Thanks,  
Tran
