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 #ifndef IVL_DETAILS_ARRAY_SUBARRAY_HPP 00025 #define IVL_DETAILS_ARRAY_SUBARRAY_HPP 00026 00027 namespace ivl { 00028 00029 namespace array_details { 00030 00031 template <class A, class I> 00032 struct subarray_result 00033 { 00034 typedef typename types::t_if<types::is_const<A>, 00035 const typename A::derived_type, typename A::derived_type>::type a; 00036 00037 typedef typename types::change_data_class_set< 00038 data::subarray<a, I>, typename A::derived_type>::type type; 00039 }; 00040 00041 } /* namespace array_details */ 00042 00043 template <class A, class I> 00044 class subarray : public array_details::subarray_result<A, I>::type 00045 { 00046 public: 00047 //operator subarray&() const { } //TODO: lets see.. 00048 //subarray& operator*() { return const_cast<subarray&>(*this); } 00049 subarray& ref() { return *this; } 00050 00051 typedef typename array_details::subarray_result<A, I>::type base_class; 00052 00053 typedef typename base_class::elem_type elem_type; 00054 00055 base_class& base() 00056 { return static_cast<base_class&>(*this); } 00057 const base_class& base() const 00058 { return static_cast<const base_class&>(*this); } 00059 00060 subarray() {} 00061 00062 subarray(A& a, const I& i) { this->setref(a.derived(), i); } 00063 00064 subarray(const subarray& a) : base_class(a.derived()) { } 00065 00066 template<class J, class S> 00067 explicit subarray(array<J, S>& o) : base_class(o) { } 00068 00069 template<class J, class S> 00070 explicit subarray(const array<J, S>& o) : base_class(o) { } 00071 00072 00073 using base_class::operator(); 00074 00075 //using base_class::operator=; 00076 template<class K> 00077 subarray& operator=(const K& k) 00078 { base_class::operator=(k); return *this; } 00079 00080 subarray& operator=(const subarray& o) 00081 { base_class::operator=(o); return *this; } 00082 00083 /* 00084 subarray& operator=(const elem_type& o) 00085 { base_class::operator=(o); return *this; } 00086 00087 template <class S, class K> 00088 subarray& operator=(const ivl::array_nd<elem_type, S, K>& o) 00089 { base_class::operator=(o); return *this; } 00090 00091 template <class S, class K> 00092 subarray& operator=(const ivl::array<elem_type, S, K>& o) 00093 { base_class::operator=(o); return *this; } 00094 */ 00095 00096 }; 00097 00098 } /* namespace ivl */ 00099 00100 #endif // IVL_DETAILS_ARRAY_SUBARRAY_HPP