view src/sdl/Array.h @ 589:d9d86f6018e8

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