Vector of Vector of Objects

What is the best way to move vector of vector of objects?

For e.g.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

template<typename T>
class A{
  private:
  vector<vector<T>> m_object; 
  public:
  vector<vector<T>> getObject(){
    return m_object;
  }
};

int main(){
  typedef boost::tuples<int, int, int> object;
  vector<vector<object>> my_object;

  A<object> my_class;
  
  my_object = my_class.getObject();
  return 0;
}


How does the vector elements are copied? what is the best way to write a code that does a functionality similarity to the one written above?
Your getObject() function does return a full copy the vector of vectors as per its copy constructor. I would instead return a reference to the stored one inside the class, unless that violates the encapsulation of the data:

vector<vector<T>>& getObject() { return m_object; }
Topic archived. No new replies allowed.