SourceForge Logo Tiny Vector Matrix library using Expression Templates Sourceforge Project Page

include/tvmet/AliasProxy.h

Go to the documentation of this file.
00001 /*
00002  * Tiny Vector Matrix Library
00003  * Dense Vector Matrix Libary of Tiny size using Expression Templates
00004  *
00005  * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net>
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * $Id: AliasProxy.h,v 1.8 2007-06-23 15:58:58 opetzold Exp $
00022  */
00023 
00024 #ifndef TVMET_ALIAS_PROXY_H
00025 #define TVMET_ALIAS_PROXY_H
00026 
00027 namespace tvmet {
00028 
00029 
00031 template<class E> class AliasProxy;
00032 
00033 
00048 template<class E>
00049 AliasProxy<E> alias(E& expr) { return AliasProxy<E>(expr); }
00050 
00051 
00066 template<class E>
00067 class AliasProxy
00068 {
00069   AliasProxy(const AliasProxy&);
00070   AliasProxy& operator=(const AliasProxy&);
00071 
00072   friend AliasProxy<E> alias<>(E& expr);
00073 
00074 public:
00075   AliasProxy(E& expr) : m_expr(expr) { }
00076 
00077 
00078   template<class E2>
00079   E& operator=(const E2& expr) {
00080     return m_expr.alias_assign(expr);
00081   }
00082 
00083   template<class E2>
00084   E& operator+=(const E2& expr) {
00085     return m_expr.alias_add_eq(expr);
00086   }
00087 
00088   template<class E2>
00089   E& operator-=(const E2& expr) {
00090     return m_expr.alias_sub_eq(expr);
00091   }
00092 
00093   template<class E2>
00094   E& operator*=(const E2& expr) {
00095     return m_expr.alias_mul_eq(expr);
00096   }
00097 
00098   template<class E2>
00099   E& operator/=(const E2& expr) {
00100     return m_expr.alias_div_eq(expr);
00101   }
00102 
00103 private:
00104   E&            m_expr;
00105 };
00106 
00107 
00108 #if 0
00109 namespace element_wise {
00110 // \todo to write
00111 template<class E, class E2>
00112 E& operator/=(AliasProxy<E>& proxy, const E2& rhs) {
00113   return proxy.div_upd(rhs);
00114 }
00115 
00116 }
00117 #endif
00118 
00119 
00120 } // namespace tvmet
00121 
00122 
00123 #endif /* TVMET_ALIAS_PROXY_H */
00124 
00125 // Local Variables:
00126 // mode:C++
00127 // tab-width:8
00128 // End:

Author: