added workaround for std::vector<bool> bitwise implementation.
The workaround is a rough reimplementation of std::vector. If you can, use "char" as temporary data and cast it when you need.
This commit is contained in:
parent
274e20b3df
commit
b6f21780dc
|
@ -63,6 +63,45 @@ public:
|
|||
virtual int SizeOf() const = 0;
|
||||
};
|
||||
|
||||
template <class TYPE>
|
||||
struct VectorNBW: public std::vector<TYPE> {};
|
||||
|
||||
template <>
|
||||
class VectorNBW<bool>{
|
||||
public:
|
||||
VectorNBW():data(0),datasize(0),datareserve(0){}
|
||||
bool * data ;
|
||||
|
||||
void reserve (const int & sz) {
|
||||
if(sz<=datareserve) return;
|
||||
bool * newdataLoc = new bool[ sz ];
|
||||
if(datasize!=0) memcpy(newdataLoc,data,sizeof(datasize));
|
||||
std::swap(data,newdataLoc);
|
||||
if(newdataLoc != 0) delete newdataLoc;
|
||||
datareserve = sz;
|
||||
}
|
||||
|
||||
void resize (const int & sz) {
|
||||
int oldDatasize = datasize;
|
||||
datasize = sz;
|
||||
if(datasize <= oldDatasize) return;
|
||||
if(datasize > datareserve)
|
||||
reserve(datasize);
|
||||
memset(&data[oldDatasize],0,datasize-oldDatasize);
|
||||
}
|
||||
void push_back(const bool & v) { resize(datasize+1); data[datasize] = v;}
|
||||
|
||||
void clear(){ datasize = 0;}
|
||||
|
||||
const unsigned int & size() const { return datasize;}
|
||||
|
||||
bool & operator [](const int & i){return data[i];}
|
||||
|
||||
private:
|
||||
int datasize;
|
||||
int datareserve;
|
||||
};
|
||||
|
||||
template <class STL_CONT, class ATTR_TYPE>
|
||||
class SimpleTempData:public SimpleTempDataBase<STL_CONT>{
|
||||
|
||||
|
@ -71,7 +110,7 @@ typedef SimpleTempData<STL_CONT,ATTR_TYPE> SimpTempDataType;
|
|||
typedef ATTR_TYPE AttrType;
|
||||
|
||||
STL_CONT& c;
|
||||
std::vector<ATTR_TYPE> data;
|
||||
VectorNBW<ATTR_TYPE> data;
|
||||
|
||||
SimpleTempData(STL_CONT &_c):c(_c){data.reserve(c.capacity());data.resize(c.size());};
|
||||
SimpleTempData(STL_CONT &_c, const ATTR_TYPE &val):c(_c){
|
||||
|
|
Loading…
Reference in New Issue