From 26a97259f5a7b066cff2927e88c867fac2aaad87 Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 26 May 2009 23:10:13 +0200 Subject: template FTW!!!!!11 --- ue4/mycpu/cmem.h | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'ue4/mycpu/cmem.h') diff --git a/ue4/mycpu/cmem.h b/ue4/mycpu/cmem.h index 5045c34..6b23111 100644 --- a/ue4/mycpu/cmem.h +++ b/ue4/mycpu/cmem.h @@ -2,7 +2,7 @@ * @module cmem * @author Guenther Neuwirth (0626638), Manuel Mausz (0728348) * @brief Memory template and memory definition for CCPU - * @date 10.05.2009 + * @date 26.05.2009 */ #ifndef CMEM_H @@ -17,21 +17,23 @@ # include # include #endif -#include "cdat.h" /** - * @class CVectorMem + * @class CMem * * Extends std::vector template for use as memory for CCPU. */ -template > -class CVectorMem - : public std::vector +template +class CMem + : public std::vector { - public: - using std::vector::size; - using std::vector::at; + typedef std::vector super; + typedef typename super::iterator iterator; + using super::size; + using super::begin; + using super::end; + public: /** * @method initialize * @brief initialize the vector with the content of istream. istream is @@ -88,22 +90,17 @@ class CVectorMem void dump(std::ostream& out) { out << "[MEMORY DUMP]" << std::endl; - for(unsigned i = 0; i < size(); ++i) + unsigned i = 0; + for(iterator it = begin(); it != end(); ++it) { out << "[" << std::setw(4) << std::setfill('0') << i << "] " - << at(i) << std::endl; + << *it << std::endl; + ++i; } } #endif }; -/** - * @class CMem - * - * Memory definition for CCPU - */ -typedef CVectorMem CMem; - #endif /* vim: set et sw=2 ts=2: */ -- cgit v1.2.3