ivl 679
|
00001 /* This file is part of the ivl C++ library <http://image.ntua.gr/ivl>. 00002 A C++ template library extending syntax towards mathematical notation. 00003 00004 Copyright (C) 2012 Yannis Avrithis <iavr@image.ntua.gr> 00005 Copyright (C) 2012 Kimon Kontosis <kimonas@image.ntua.gr> 00006 00007 ivl is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU Lesser General Public License 00009 version 3 as published by the Free Software Foundation. 00010 00011 Alternatively, you can redistribute it and/or modify it under the terms 00012 of the GNU General Public License version 2 as published by the Free 00013 Software Foundation. 00014 00015 ivl is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00018 See the GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 and a copy of the GNU Lesser General Public License along 00022 with ivl. If not, see <http://www.gnu.org/licenses/>. */ 00023 00024 00030 template <class T, 00031 class DERIVED_INFO 00032 > 00033 class array<T, data::empty<DERIVED_INFO> > : 00034 public array_common_base<array<T, data::empty<DERIVED_INFO> > > 00035 { 00036 00037 private: 00038 typedef array_common_base<array< 00039 T, data::empty<DERIVED_INFO> > > common_base_class; 00040 00041 protected: 00042 00043 public: 00044 typedef array this_type; 00045 00046 typedef this_type this_array_type; 00047 00048 typedef this_type array_type; 00049 00050 typedef T elem_type; 00051 00052 typedef const T& const_reference; 00053 typedef const_reference best_reference; 00054 00055 typedef typename this_type::derived_type derived_type; 00056 00057 typedef typename common_base_class::base_class base_class; 00058 00059 typedef size_t size_type; 00060 00061 using base_class::derived; 00062 00063 struct iter_border_walker { 00064 iter_border_walker() {} 00065 iter_border_walker(ptrdiff_t) {} 00066 template <class IT> 00067 iter_border_walker(const IT&, const IT&) {} 00068 }; 00069 00070 class const_iterator 00071 : public types::border_walker_iterator_identifier 00072 { 00073 public: 00074 // iterator_traits 00075 typedef std::random_access_iterator_tag iterator_category; 00076 typedef typename types::remove_const<T>::type value_type; 00077 typedef ptrdiff_t difference_type; 00078 typedef const value_type* pointer; 00079 typedef const value_type& reference; 00080 00081 // border_walker 00082 typedef typename array::iter_border_walker iter_border_walker; 00083 00084 const_iterator() { } 00085 const_iterator(const const_iterator& it) { } 00086 00087 const_iterator& operator++() { return *this; } 00088 const_iterator& operator--() { return *this; } 00089 00090 const_iterator operator++(int) { return const_iterator(); } 00091 const_iterator operator--(int) { return const_iterator(); } 00092 00093 // random access 00094 const_iterator operator +(const difference_type i) const 00095 { return const_iterator(); } 00096 const_iterator operator -(const difference_type i) const 00097 { return const_iterator(); } 00098 const_iterator& operator +=(const difference_type i) { return *this; } 00099 const_iterator& operator -=(const difference_type i) { return *this; } 00100 00101 const T operator *() const { return T(0); } 00102 00103 const T* operator ->() const { return NULL; } 00104 00105 const T operator [] (size_t j) const { return T(0); } 00106 00107 const_iterator& operator=(const const_iterator& it) { return *this; } 00108 00109 bool operator==(const const_iterator& it) const { return true; } 00110 bool operator!=(const const_iterator& it) const { return false; } 00111 00112 }; 00113 00114 typedef const_iterator best_iterator; 00115 00116 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 00117 00118 const_iterator begin() const { return const_iterator(); } 00119 const_iterator end() const { return const_iterator(); } 00120 const_reverse_iterator rbegin() const { return const_iterator(); } 00121 const_reverse_iterator rend() const { return const_iterator(); } 00122 00125 //TODO: explain this better. 00127 size_t length() const { return 0; } 00129 size_type size() const { return 0; } 00131 size_t numel() const { return 0; } 00134 iter_border_walker first_to_last() { return iter_border_walker(); } 00135 iter_border_walker begin_to_end() { return iter_border_walker(); } 00136 00142 00143 00144 00145 00146 00147 T operator[] (size_t i) const { return T(); } 00150 static derived_type instance; 00151 00154 00155 array() { } 00156 00158 array(const this_type& a) { } 00159 00161 ~array() { } 00162 00174 this_type& operator=(const this_type& a) // LEFT IN THE CONST MODE FOR A COPY CONSTRUCTOR! 00175 { 00176 } 00177 00178 00179 }; 00180 00183 template<class T> 00184 inline 00185 array<T, data::empty<> > empty() 00186 { 00187 return array<T, data::empty<> >(); 00188 }