Mercurial > vba-clojure
view src/sdl/Array.h @ 274:210b465e4720
refactored walking code from buy-initial-objects to its own function.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 27 Mar 2012 11:30:58 -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_H20 #define ARRAY_H22 #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