annotate src/sdl/Array.h @ 52:9f63ad276c0d tip

enabled dev mode.
author Robert McIntyre <rlm@mit.edu>
date Thu, 21 Mar 2013 21:42:44 +0000
parents f9f4f1b99eed
children
rev   line source
rlm@1 1 /***************************************************************************
rlm@1 2 * Copyright (C) 2008 by Sindre Aam�s *
rlm@1 3 * aamas@stud.ntnu.no *
rlm@1 4 * *
rlm@1 5 * This program is free software; you can redistribute it and/or modify *
rlm@1 6 * it under the terms of the GNU General Public License version 2 as *
rlm@1 7 * published by the Free Software Foundation. *
rlm@1 8 * *
rlm@1 9 * This program is distributed in the hope that it will be useful, *
rlm@1 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
rlm@1 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
rlm@1 12 * GNU General Public License version 2 for more details. *
rlm@1 13 * *
rlm@1 14 * You should have received a copy of the GNU General Public License *
rlm@1 15 * version 2 along with this program; if not, write to the *
rlm@1 16 * Free Software Foundation, Inc., *
rlm@1 17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
rlm@1 18 ***************************************************************************/
rlm@1 19 #ifndef ARRAY_H
rlm@1 20 #define ARRAY_H
rlm@1 21
rlm@1 22 #include <cstddef>
rlm@1 23
rlm@1 24 template<typename T>
rlm@1 25 class Array {
rlm@1 26 T *a;
rlm@1 27 std::size_t sz;
rlm@1 28
rlm@1 29 Array(const Array &ar);
rlm@1 30
rlm@1 31 public:
rlm@1 32 Array(const std::size_t size = 0) : a(size ? new T[size] : 0), sz(size) {}
rlm@1 33 ~Array() { delete []a; }
rlm@1 34 void reset(const std::size_t size) { delete []a; a = size ? new T[size] : 0; sz = size; }
rlm@1 35 std::size_t size() const { return sz; }
rlm@1 36 operator T*() { return a; }
rlm@1 37 operator const T*() const { return a; }
rlm@1 38 };
rlm@1 39
rlm@1 40 #endif