misc.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002     
00003     misc.hpp -- miscellaneous features
00004 
00005     This file is part of the Arageli library.
00006 
00007     Copyright (C) Nikolai Yu. Zolotykh, 1999--2006
00008     Copyright (C) Sergey S. Lyalin, 2005
00009     University of Nizhni Novgorod, Russia
00010 
00011 *****************************************************************************/
00012 
00019 #ifndef _ARAGELI_misc_hpp_
00020 #define _ARAGELI_misc_hpp_
00021 
00022 #include "config.hpp"
00023 
00024 
00025 namespace Arageli
00026 {
00027 
00028 
00030 
00035 template <typename T>
00036 T safe_reference (const T& x) { return x; }
00037 
00038 
00039 template <typename T1, typename T2, typename Outiter>
00040 void generate_range_helper (T1& t1, const T2& t2, Outiter outiter)
00041 {
00042     //std::cerr << "\nt1 = " << t1 << ", t2 = " << t2 << ":\n\t";
00043 
00044     if(t1 < t2)
00045         for(; t1 != t2; ++t1/*, std::cerr << t1 << "  "*/)
00046             *outiter++ = t1;
00047     else
00048         for(; t1 != t2; --t1/*, std::cerr << t1 << "  "*/)
00049             *outiter++ = t1;
00050 
00051     *outiter = t1;
00052 }
00053 
00054 
00055 template <typename T1, typename T2, typename T3, typename Outiter>
00056 void generate_range_helper (T1& t1, const T2& t2, const T3& t3, Outiter outiter)
00057 {
00058     for(; t1 != t3; t1 += t2, ++outiter)
00059         *outiter = t1;
00060 
00061     *outiter = t1;
00062 }
00063 
00064 
00065 template <typename T1, typename T2, typename Outiter>
00066 void generate_range_helper_wo_inc (T1& t1, const T2& t2, Outiter outiter)
00067 {
00068     //std::cerr << "\nt1 = " << t1 << ", t2 = " << t2 << ":\n\t";
00069 
00070     if(t1 < t2)
00071         for(; t1 != t2; t1 += unit(t1)/*, std::cerr << t1 << "  "*/)
00072             *outiter++ = t1;
00073     else
00074         for(; t1 != t2; t1 -= unit(t1)/*, std::cerr << t1 << "  "*/)
00075             *outiter++ = t1;
00076 
00077     *outiter = t1;
00078 }
00079 
00080 
00081 template <typename Outiter>
00082 inline void generate_range_helper (bool& t1, bool t2, Outiter outiter)
00083 { generate_range_helper_wo_inc(t1, t2, outiter); }
00084 
00085 template <typename Outiter>
00086 inline void generate_range_helper (float& t1, float t2, Outiter outiter)
00087 { generate_range_helper_wo_inc(t1, t2, outiter); }
00088 
00089 template <typename Outiter>
00090 inline void generate_range_helper (double& t1, double t2, Outiter outiter)
00091 { generate_range_helper_wo_inc(t1, t2, outiter); }
00092 
00093 template <typename Outiter>
00094 inline void generate_range_helper (long double& t1, long double t2, Outiter outiter)
00095 { generate_range_helper_wo_inc(t1, t2, outiter); }
00096 
00097 
00098 template <typename T> struct cnc_value_type
00099 { typedef typename T::value_type type; };
00100 
00101 template <typename T> struct cnc_value_type<const T>
00102 { typedef typename T::value_type const type; };
00103 
00104 
00105 template <typename T> struct cnc_reference
00106 { typedef typename T::reference type; };
00107 
00108 template <typename T> struct cnc_reference<const T>
00109 { typedef typename T::const_reference type; };
00110 
00111 
00112 template <typename T> struct cnc_pointer
00113 { typedef typename T::pointer type; };
00114 
00115 template <typename T> struct cnc_pointer<const T>
00116 { typedef typename T::const_pointer type; };
00117 
00118 
00119 template <typename T> struct cnc_iterator
00120 { typedef typename T::iterator type; };
00121 
00122 template <typename T> struct cnc_iterator<const T>
00123 { typedef typename T::const_iterator type; };
00124 
00125 
00126 } // namespace Arageli
00127 
00128 
00129 
00130 //#ifdef ARAGELI_INCLUDE_CPP_WITH_EXPORT_TEMPLATE
00131 //  #define ARAGELI_INCLUDE_CPP_WITH_EXPORT_TEMPLATE_MISC
00132 //  #include "misc.cpp"
00133 //  #undef  ARAGELI_INCLUDE_CPP_WITH_EXPORT_TEMPLATE_MISC
00134 //#endif
00135 
00136 
00137 #endif  //  #ifndef _ARAGELI_misc_hpp_

Generated on Thu Aug 31 17:38:08 2006 for Arageli by  doxygen 1.4.7