c++ - I am trying to make my own version of vector's swap in C++03 and am completely stuck/baffled by error -
i trying make swap method in version of vector class uses c++03 format without boost. code have is
template <class t> void kvector<t>::swap(kvector<t> &in) { kvector<t>* temp = ∈ //copying pointer of in temp , therefore bypassing assignment operator //now switch in , , , temp using pointer arithmetic again bypass assignment operator //!note: pointer based arithmetic used in swap method exponentially faster using //!assignment operator or copy constructor &in = this; = temp; //!no need set data pointer of temp 0 since temp pointer , not //!deleted automatically. since both in , still exist @ end of method //!than no memory can leak method } which attempts pass around vectors pointers. getting error &in = this; , this = temp;. error expression 'not assignable'. don't understand error means , why error. can please explain this? baffled.
Comments
Post a Comment