ivl 679
ivl/details/array/impl/iter_array.hpp
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 #ifndef IVL_ARRAY_DETAILS_ITER_ARRAY_HPP
00025 #define IVL_ARRAY_DETAILS_ITER_ARRAY_HPP
00026 
00027 namespace ivl {
00028 
00029 
00030 template<class T, int N>
00031 array<T, rw_link> lnk(T (&a)[N])
00032 {
00033         return array<T, rw_link>(N, a);
00034 }
00035 
00036 template<class T, int N>
00037 array<T, const_link> lnk(const T (&a)[N])
00038 {
00039         return array<T, const_link>(N, a);
00040 }
00041 
00042 //
00043 #if 0
00044 
00045 template<class A>
00046 array<typename A::elem_type, const_link>
00047         const_iter_array(const A& a)
00048 {
00049         return array<typename A::elem_type, const_link>(a);
00050 }
00051 
00052 template<class A>
00053 array<typename A::elem_type, const_link>
00054         iter_array(const A& a)
00055 {
00056         return array<typename A::elem_type, const_link>(a);
00057 }
00058 
00059 template<class A>
00060 array<typename A::elem_type, rw_link>
00061         iter_array(A& a)
00062 {
00063         return array<typename A::elem_type, rw_link>(a);
00064 }
00065 
00066 // ----
00067 
00068 template<class A>
00069 array<typename A::elem_type, const_link>
00070         const_iter_array(const A& a, size_t l)
00071 {
00072         return array<typename A::elem_type, const_link>(l, a);
00073 }
00074 
00075 template<class A>
00076 array<typename A::elem_type, const_link>
00077         iter_array(const A& a, size_t l)
00078 {
00079         return array<typename A::elem_type, const_link>(l, a);
00080 }
00081 
00082 template<class A>
00083 array<typename A::elem_type, rw_link>
00084         iter_array(A& a, size_t l)
00085 {
00086         return array<typename A::elem_type, rw_link>(l, a);
00087 }
00088 
00089 // ----
00090 
00091 template<class T>
00092 array<T, typename const_link>
00093         const_iter_array(const T* a, size_t l)
00094 {
00095         return array<T, const_link> r(a, l);
00096 }
00097 
00098 template<class T>
00099 array<T, typename const_link>
00100         iter_array(const T* a, size_t l)
00101 {
00102         return array<T, const_link> r(a, l);
00103 }
00104 
00105 template<class T>
00106 array<T, typename rw_link>
00107         iter_array(T* a, size_t l)
00108 {
00109         return array<T, rw_link> r(a, l);
00110 }
00111 
00112 
00113 /*
00114 template<class CONST_IT>
00115 array<typename CONST_IT::value_type,
00116         typename data::ref_iterator<0, CONST_IT, types::term>::type>
00117         const_iter_array(const CONST_IT& it)
00118 {
00119         return array<typename CONST_IT::value_type,
00120         typename data::ref_iterator_traits<0, CONST_IT, types::term>::type>(it);
00121 }
00122 
00123 template<class IT>
00124 array<typename IT::value_type,
00125         typename data::ref_iterator<0, IT, types::term>::type>
00126         iter_array(const IT& it)
00127 {
00128         return array<typename IT::value_type,
00129         typename data::ref_iterator_traits<0, IT, types::term>::type>(it);
00130 }
00131 */
00132 
00133 #if 0
00134 // well written definitions
00135 template
00136 <
00137 class T,
00138 class CONST_IT,
00139 int N = 0,
00140 class DATA_CLASS_SET = typename
00141         data::ref_iterator_traits<N, CONST_IT, types::term>::type
00142 >
00143 class const_iter_array :
00144         public
00145         array<T, DATA_CLASS_SET, types::term>
00146 {
00147 public:
00148         typedef const_iter_array this_type;
00149 
00150         typedef array<T, DATA_CLASS_SET, types::term> base_class;
00151 
00152         const_iter_array(const CONST_IT& it) : base_class(it) { }
00153 
00154         const_iter_array(const CONST_IT& it, const CONST_IT& e)
00155         : base_class(it, e - it, e) { }
00156 
00157         const_iter_array(const CONST_IT& it, int n)
00158         : base_class(it, n, it + n) { }
00159 
00160         using base_class::operator=;
00161         this_type& operator = (const this_type& o) {
00162                 return base_class::operator=(o);
00163         }
00164 
00165 };
00166 
00167 
00168 template
00169 <
00170 class T,
00171 class IT,
00172 class CONST_IT,
00173 int N = 0,
00174 class DATA_CLASS_SET = typename
00175         data::ref_iterator_traits<N, IT, CONST_IT>::type
00176 >
00177 class iter_array :
00178         public
00179         array<T, DATA_CLASS_SET, types::term>
00180 {
00181 public:
00182         typedef iter_array this_type;
00183 
00184         typedef array<T, DATA_CLASS_SET,
00185                 typename types::derive<this_type>::type> base_class;
00186 
00187         iter_array(const IT& it) : base_class(it) { }
00188 
00189         iter_array(const IT& it, const IT& e) : base_class(it, e - it, e) { }
00190 
00191         iter_array(const IT& it, int n) : base_class(it, n, it + n) { }
00192 
00193         using base_class::operator=;
00194         this_type& operator = (const this_type& o) {
00195                 return base_class::operator=(o);
00196         }
00197 };
00198 #endif
00199 #endif
00200 
00201 
00202 }; /*namespace ivl*/
00203 
00204 #endif // IVL_ARRAY_DETAILS_TUPLE_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations