From f2fde4de52d4513689308b42e30acdeb2401d083 Mon Sep 17 00:00:00 2001 From: ganovelli Date: Sat, 11 Dec 2004 15:37:47 +0000 Subject: [PATCH] added one more [], now it is polymorphic, added typenames --- vcg/container/simple_temporary_data.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vcg/container/simple_temporary_data.h b/vcg/container/simple_temporary_data.h index e80ea37c..ede41197 100644 --- a/vcg/container/simple_temporary_data.h +++ b/vcg/container/simple_temporary_data.h @@ -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 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::iterator i; + for(i = data.begin(); i!= data.end(); ++i) + *i = val; +} + // stop temporary attribute void Stop(){data.clear();}