-4

I want to get the size of a nested deque, like this one:

typedef struct{
deque<int>   vec1;
deque<int>   vec2;
deque<int>   vec3;
}struct_deques;

deque<struct_deques> nestedVecs;

However, when I want to access the size of the first deque, after filling it with data, it is possible with:

nestedVec.size();

But if I want to get the size of a nested deque, I am getting 0:

nestedVec.vec1.size();

There is data in it and I can access it, but I can not get the size. Is there a way to get the size of a nested deque?

Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62
Firas94
  • 1
  • 1

1 Answers1

2

You need to specify which structure inside the deque you want to access.

nestedVec[i].vec1.size(); // note the [i]

Otherwise there is no way to be able to figure out which structure you want to get and which deque to access.

Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62
  • I am sorry, i forgot the index here in this post! I corrected it, but i made it right in my code, but it does not work either. – Firas94 Jan 14 '19 at 10:31
  • 1
    It does, that's how you get the size of your dequeue. Otherwise, it's an issue int he code you are not showing. – Matthieu Brucher Jan 14 '19 at 10:33
  • either the edit of the question should be rolled back or this answer is completely pointless, @Firas94 in any case, you should tell us the exact error and show the code that causes the error – 463035818_is_not_an_ai Jan 14 '19 at 11:21
  • @user463035818 I hope OP will update the question, then I can edit the answer for something more adapted (or indeed, roll it back). – Matthieu Brucher Jan 14 '19 at 11:23