00001 // Software License for MTL 00002 // 00003 // Copyright (c) 2007 The Trustees of Indiana University. 00004 // 2008 Dresden University of Technology and the Trustees of Indiana University. 00005 // All rights reserved. 00006 // Authors: Peter Gottschling and Andrew Lumsdaine 00007 // 00008 // This file is part of the Matrix Template Library 00009 // 00010 // See also license.mtl.txt in the distribution. 00011 00012 #ifndef MTL_VECTOR_VEC_CONST_REF_EXPR_INCLUDE 00013 #define MTL_VECTOR_VEC_CONST_REF_EXPR_INCLUDE 00014 00015 namespace mtl { namespace vector { 00016 00017 00019 template <typename Vector> 00020 struct vec_const_ref_expr 00021 : vec_expr< vec_const_ref_expr<Vector> > 00022 { 00023 typedef vec_const_ref_expr self; 00024 typedef typename Vector::size_type size_type; 00025 typedef typename Vector::value_type value_type; 00026 typedef value_type const_dereference_type ; 00027 00028 vec_const_ref_expr(const Vector& ref) : ref(ref) {} 00029 00030 void delay_assign() const {} 00031 00032 size_type size() const 00033 { 00034 return ref.size(); 00035 } 00036 00037 const_dereference_type operator() ( size_type i ) const 00038 { 00039 return ref(i); 00040 } 00041 00042 const_dereference_type operator[] ( size_type i ) const 00043 { 00044 return ref[i]; 00045 } 00046 00047 00048 00049 private: 00050 const Vector& ref; 00051 }; 00052 00053 00054 }} // namespace mtl::vector 00055 00056 #endif // MTL_VECTOR_VEC_CONST_REF_EXPR_INCLUDE