From 2c0bf4d7935626ef299f1be3f992b1dfe4c0b19f Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 4 Jun 2009 16:31:09 +0200 Subject: shared_ptr --- ue5/array.hpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'ue5/array.hpp') diff --git a/ue5/array.hpp b/ue5/array.hpp index 9c8a7e6..e9adc55 100644 --- a/ue5/array.hpp +++ b/ue5/array.hpp @@ -22,21 +22,21 @@ namespace Ti void fill(const T& u) { - for(size_type i = 0; i < size(); ++i) - m_data[i] = u; /* std::fill_n(begin(), size(), u); */ + for(size_type i = 0; i < N; ++i) + m_data[i] = u; } /* range check not necessary. N must be the same in other */ void swap(array & other) { - for(size_type i = 0; i < size(); ++i) + /* std::swap_ranges(begin(), end(), other.begin()); */ + for(size_type i = 0; i < N; ++i) { T x(m_data[i]); - m_data[i] = other[i]; - other[i] = x; + m_data[i] = other.m_data[i]; + other.m_data[i] = x; } - /* std::swap_ranges(begin(), end(), other.begin()); */ } iterator begin() @@ -51,12 +51,12 @@ namespace Ti iterator end() { - return m_data + size(); + return m_data + N; } const_iterator end() const { - return m_data + size(); + return m_data + N; } size_type size() const @@ -86,14 +86,14 @@ namespace Ti reference at(size_type n) { - if (n >= size()) + if (n >= N) throw std::out_of_range("array::at"); return m_data[n]; } const_reference at(size_type n) const { - if (n >= size()) + if (n >= N) throw std::out_of_range("array::at"); return m_data[n]; } @@ -107,7 +107,7 @@ namespace Ti T m_data[N]; }; - /* std::move makes rvalue from rvalue */ + /* std::move returns lvalue as rvalue */ template array&& make_array() { -- cgit v1.2.3