rlm@1: /*************************************************************************** rlm@1: * Copyright (C) 2008 by Sindre Aam�s * rlm@1: * aamas@stud.ntnu.no * rlm@1: * * rlm@1: * This program is free software; you can redistribute it and/or modify * rlm@1: * it under the terms of the GNU General Public License version 2 as * rlm@1: * published by the Free Software Foundation. * rlm@1: * * rlm@1: * This program is distributed in the hope that it will be useful, * rlm@1: * but WITHOUT ANY WARRANTY; without even the implied warranty of * rlm@1: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * rlm@1: * GNU General Public License version 2 for more details. * rlm@1: * * rlm@1: * You should have received a copy of the GNU General Public License * rlm@1: * version 2 along with this program; if not, write to the * rlm@1: * Free Software Foundation, Inc., * rlm@1: * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * rlm@1: ***************************************************************************/ rlm@1: #ifndef ARRAY_H rlm@1: #define ARRAY_H rlm@1: rlm@1: #include rlm@1: rlm@1: template rlm@1: class Array { rlm@1: T *a; rlm@1: std::size_t sz; rlm@1: rlm@1: Array(const Array &ar); rlm@1: rlm@1: public: rlm@1: Array(const std::size_t size = 0) : a(size ? new T[size] : 0), sz(size) {} rlm@1: ~Array() { delete []a; } rlm@1: void reset(const std::size_t size) { delete []a; a = size ? new T[size] : 0; sz = size; } rlm@1: std::size_t size() const { return sz; } rlm@1: operator T*() { return a; } rlm@1: operator const T*() const { return a; } rlm@1: }; rlm@1: rlm@1: #endif