added one more [], now it is polymorphic, added typenames

This commit is contained in:
ganovelli 2004-12-11 15:37:47 +00:00
parent 3edef6bc60
commit f2fde4de52
1 changed files with 12 additions and 1 deletions

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.2 2004/03/31 22:36:44 ganovelli
First Working Release (with this comment)
/****************************************************************************/
@ -45,12 +48,20 @@ std::vector<ATTR_TYPE> data;
SimpleTempData(STL_CONT &_c):c(_c){};
// access to data
ATTR_TYPE & operator[](const STL_CONT::value_type *v){return data[v-&*c.begin()];}
ATTR_TYPE & operator[](const typename STL_CONT::value_type & v){return data[&v-&*c.begin()];}
ATTR_TYPE & operator[](const typename STL_CONT::value_type * v){return data[v-&*c.begin()];}
ATTR_TYPE & operator[](const int & i){return data[i];}
// start temporary attribute
void Start(){data.reserve(c.capacity());data.resize(c.size());}
// start and initialize temporary attribute
void Start(ATTR_TYPE val){data.reserve(c.capacity());data.resize(c.size());
std::vector<ATTR_TYPE>::iterator i;
for(i = data.begin(); i!= data.end(); ++i)
*i = val;
}
// stop temporary attribute
void Stop(){data.clear();}