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

include/tvmet/xpr/Literal.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: Literal.h,v 1.13 2007-06-23 15:58:59 opetzold Exp $
00022  */
00023 
00024 #ifndef TVMET_XPR_LITERAL_H
00025 #define TVMET_XPR_LITERAL_H
00026 
00027 namespace tvmet {
00028 
00029 
00036 template<class T>
00037 class XprLiteral
00038   : public TvmetBase< XprLiteral<T> >
00039 {
00040   XprLiteral();
00041   XprLiteral& operator=(const XprLiteral&);
00042 
00043 public:
00044   typedef T           value_type;
00045 
00046 public:
00048   enum {
00049     ops       = 1
00050   };
00051 
00052 public:
00054   explicit XprLiteral(value_type value)
00055     : m_data(value)
00056   { }
00057 
00059 #if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR)
00060   XprLiteral(const XprLiteral& e)
00061     : m_data(e.m_data)
00062   { }
00063 #endif
00064 
00066   value_type operator()(std::size_t) const { return m_data; }
00067 
00069   value_type operator()(std::size_t, std::size_t) const { return m_data; }
00070 
00071 public: // debugging Xpr parse tree
00072   void print_xpr(std::ostream& os, std::size_t l=0) const {
00073     os << IndentLevel(l++) << "XprLiteral[O=" << ops << "]<T="
00074        << typeid(value_type).name()
00075        << ">," << std::endl;
00076   }
00077 
00078 private:
00079   const value_type          m_data;
00080 };
00081 
00082 
00083 } // namespace tvmet
00084 
00085 #endif // TVMET_XPR_LITERAL_H
00086 
00087 // Local Variables:
00088 // mode:C++
00089 // tab-width:8
00090 // End:

Author: