From 65223d706951721fe6c6a8c8bb21f9a866de7e40 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Tue, 7 Jul 2009 11:29:31 +0200 Subject: [PATCH] Fixed size array --- src/fixArray.hpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/fixArray.hpp diff --git a/src/fixArray.hpp b/src/fixArray.hpp new file mode 100644 index 0000000..d1516e4 --- /dev/null +++ b/src/fixArray.hpp @@ -0,0 +1,40 @@ +#ifndef __FIX_ARRAY_HPP +#define __FIX_ARRAY_HPP + +namespace CosmoTool +{ + + template class fixArray + { + private: + T d[sz]; + + public: + /*! Returns the size of the array. */ + long size() const { return sz; } + + /*! Returns a reference to element \a #n */ + template T &operator[] (T2 n) { + return d[n]; + } + + /*! Returns a constant reference to element \a #n */ + template const T &operator[] (T2 n) const { + return d[n]; + } + + template void importArray(T2 *indata) { + for (int i = 0; i < sz; i++) + d[i] = indata[i]; + } + + template void exportArray(T2 *outdata) { + for (int i = 0; i < sz; i++) + outdata[i] = d[i]; + } + + }; + +}; + +#endif