Changeset 1651
- Timestamp:
- Dec 15, 2008, 1:57:43 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEWS
r1619 r1651 5 5 Version 0.5 (released DATE) 6 6 7 - Imlicit conversion between Vector and its Views disabled (ticket:467) 7 8 - Averager::add (and siblings) take a (signed) long (ticket:361) 8 9 - IteratorPolicy removed (ticket:398) -
trunk/yat/utility/Vector.h
r1506 r1651 71 71 \throw GSL_error if memory allocation fails. 72 72 */ 73 Vector(size_t n, double init_value=0);73 explicit Vector(size_t n, double init_value=0); 74 74 75 75 /** … … 87 87 fails. 88 88 */ 89 Vector(const VectorBase& other);89 explicit Vector(const VectorBase& other); 90 90 91 91 /** -
trunk/yat/utility/VectorConstView.h
r1615 r1651 64 64 \brief Copy a VectorBase 65 65 */ 66 VectorConstView(const VectorBase& other);66 explicit VectorConstView(const VectorBase& other); 67 67 68 68 /** -
trunk/yat/utility/VectorMutable.cc
r1487 r1651 180 180 181 181 182 VectorMutable::operator proxy()183 {184 assert(vec_==const_vec_);185 proxy p;186 p.vec_ = vec_;187 vec_ = NULL; // proxy takes ownership and delivers to its receiver188 const_vec_ = NULL;189 return p;190 }191 192 182 }}} // of namespace utility, yat, and thep -
trunk/yat/utility/VectorMutable.h
r1551 r1651 220 220 gsl_vector* vec_; 221 221 222 /**223 Proxy class used to allow copy and assignment of VectorView. By224 design vectors and matrices are passed as non-const references225 in all constructors of VectorView. Because the standard does226 not allow temporary objects to be bound to non-const227 references, it is not possible to directly construct a228 VectorView from a temporary VectorView returned from a229 function. Instead this proxy class is created from the230 temporary object and then a VectorView can be created from this231 proxy.232 233 \see VectorView234 */235 struct proxy236 {237 /// pointer to GSL vector keeping everything we need to create a238 /// new VectorMutable from a proxy.239 gsl_vector* vec_;240 };241 242 222 private: 243 223 // copy assignment not allowed 244 224 const VectorMutable& operator=(const VectorMutable&); 245 public:246 /**247 conversion operator to protected proxy class.248 */249 operator proxy();250 225 251 226 }; -
trunk/yat/utility/VectorView.cc
r1487 r1651 124 124 125 125 126 127 126 const VectorView& VectorView::operator=(const VectorView& other ) 128 127 { … … 147 146 148 147 148 VectorView::operator proxy() 149 { 150 assert(vec_==const_vec_); 151 proxy p; 152 p.vec_ = vec_; 153 vec_ = NULL; // proxy takes ownership and delivers to its receiver 154 const_vec_ = NULL; 155 return p; 156 } 157 158 149 159 }}} // of namespace utility, yat, and thep -
trunk/yat/utility/VectorView.h
r1487 r1651 110 110 is undefined. 111 111 */ 112 VectorView(VectorMutable& other);112 explicit VectorView(VectorMutable& other); 113 113 114 114 /** … … 143 143 VectorView(Matrix& m, size_t i, bool row=true); 144 144 145 /**146 \brief create VectorView from proxy class147 */148 VectorView(proxy p);149 150 145 /// 151 146 /// The destructor. … … 186 181 187 182 gsl_vector_view* view_; 183 184 /** 185 Proxy class used to allow copy and assignment of VectorView. By 186 design vectors and matrices are passed as non-const references 187 in all constructors of VectorView. Because the standard does 188 not allow temporary objects to be bound to non-const 189 references, it is not possible to directly construct a 190 VectorView from a temporary VectorView returned from a 191 function. Instead this proxy class is created from the 192 temporary object and then a VectorView can be created from this 193 proxy. 194 */ 195 struct proxy 196 { 197 /// pointer to GSL vector keeping everything we need to create a 198 /// new VectorMutable from a proxy. 199 gsl_vector* vec_; 200 }; 201 202 public: 203 /** 204 \brief create VectorView from proxy class 205 */ 206 VectorView(proxy p); 207 208 /** 209 conversion operator to private proxy class. 210 */ 211 operator proxy(); 188 212 }; 189 213
Note: See TracChangeset
for help on using the changeset viewer.