• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Meta.h

Go to the documentation of this file.
00001 // GMTL is (C) Copyright 2001-2010 by Allen Bierbaum
00002 // Distributed under the GNU Lesser General Public License 2.1 with an
00003 // addendum covering inlined code. (See accompanying files LICENSE and
00004 // LICENSE.addendum or http://www.gnu.org/copyleft/lesser.txt)
00005 
00006 #ifndef _GMTL_METAPROGRAMMING_H
00007 #define _GMTL_METAPROGRAMMING_H
00008 
00009 #include <gmtl/Defines.h>
00010 
00011 /*** STRINGIZE and JOIN macros */
00012 /* Taken from boost (see boost.org) */
00013 
00014 //
00015 // Helper macro GMTL_STRINGIZE:
00016 // Converts the parameter X to a string after macro replacement
00017 // on X has been performed.
00018 //
00019 #define GMTL_STRINGIZE(X) GMTL_DO_STRINGIZE(X)
00020 #define GMTL_DO_STRINGIZE(X) #X
00021 
00022 //
00023 // Helper macro GMTL_JOIN:
00024 // The following piece of macro magic joins the two
00025 // arguments together, even when one of the arguments is
00026 // itself a macro (see 16.3.1 in C++ standard).  The key
00027 // is that macro expansion of macro arguments does not
00028 // occur in BOOST_DO_JOIN2 but does in BOOST_DO_JOIN.
00029 //
00030 #define GMTL_JOIN( X, Y ) GMTL_DO_JOIN( X, Y )
00031 #define GMTL_DO_JOIN( X, Y ) GMTL_DO_JOIN2(X,Y)
00032 #define GMTL_DO_JOIN2( X, Y ) X##Y
00033 
00034 
00036 namespace gmtl
00037 {
00040 
00046    template <typename T>
00047    struct Type2Type
00048    {
00049       typedef T OriginalType;
00050    };
00051 
00053 
00056    template <class T> inline void ignore_unused_variable_warning(const T&) { }
00057 
00059 
00060 } // end namespace
00061 
00062 #ifndef GMTL_NO_METAPROG
00063 namespace gmtl
00064 {
00065 namespace meta
00066 {
00067 
00068 // ------ LOOP UnRolling ------------ //
00069 template<int ELT, typename T>
00070 struct AssignVecUnrolled
00071 {
00072    static void func(T& lVec, const T& rVec)
00073    {
00074       AssignVecUnrolled<ELT-1,T>::func(lVec, rVec);
00075       lVec[ELT] = rVec[ELT];
00076    }
00077 };
00078 
00079 template<typename T>
00080 struct AssignVecUnrolled<0,T>
00081 {
00082    static void func(T& lVec, const T& rVec)
00083    { lVec[0] = rVec[0]; }
00084 };
00085 
00086 // Template programs for array assignment unrolled
00087 template<int ELT, typename T>
00088 struct AssignArrayUnrolled
00089 {
00090    static void func(T* lVec, const T* rVec)
00091    {
00092       AssignArrayUnrolled<ELT-1,T>::func(lVec, rVec);
00093       lVec[ELT] = rVec[ELT];
00094    }
00095 };
00096 
00097 template<typename T>
00098 struct AssignArrayUnrolled<0,T>
00099 {
00100    static void func(T* lVec, const T* rVec)
00101    { lVec[0] = rVec[0]; }
00102 };
00103 
00104 }  // namespace meta
00105 }  // namespace gmtl
00106 #endif /* ! GMTL_NO_METAPROG */
00107 
00108 #endif

Generated on Sun Sep 19 2010 14:35:14 for GenericMathTemplateLibrary by  doxygen 1.7.1