c++ - Using bitwise or equals (|= with a vector -


i can't following, compiler says no matching operator in std::vector , don't think can overload it. options, apart using 1 vector store collision results. i'm trying extremely cache friendly , don't want same bool reset false after been set true, hence or.

void collisiondetection(const vector<vector2d>& position1,                          const vector<vector2d>& position2,                         dimension dim1, dimension dim2,                          vector<bool>& result1, vector<bool>& result2) {     assert(position1.size()==result1.size());     assert(position2.size()==result2.size());      for(int i=0;i<position1.size();i++)     {         for(int j=0;j<position2.size();j++)         {             result1[i] |= result2[i] |=              rectoverlap(position1[1], position2[i], dim1, dim2);         }     } } 

std::vector<bool> specialization of std::vector. specialization saves space using 1 bit each bool, instead of 1 byte.

std::vector<bool>::operator[] returns reference wrapper(in order allow space-save optimization), apparently not implement operator|.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -