00001 // Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 00025 00026 #ifndef MLN_CORE_INTERNAL_EXACT_GCC_2_95_HH 00027 # define MLN_CORE_INTERNAL_EXACT_GCC_2_95_HH 00028 00033 00034 # include <mln/core/internal/exact.hh> 00035 00036 00037 00038 namespace mln 00039 { 00040 00041 namespace internal 00042 { 00043 00044 // For exact(T&): 00045 00046 template <typename T> 00047 struct exact_gcc_2_95 00048 { 00049 typedef typename mln::internal::exact_<T>::ret E; 00050 typedef E& ret; 00051 static ret run(T& t) 00052 { 00053 return *internal::exact_<T>::run(&t); 00054 } 00055 }; 00056 00057 template <typename T> 00058 struct exact_gcc_2_95< const T > 00059 { 00060 typedef typename mln::internal::exact_<T>::ret E; 00061 typedef const E& ret; 00062 static ret run(T& t) 00063 { 00064 return *internal::exact_<T>::run(const_cast<T*>(&t)); 00065 } 00066 }; 00067 00068 template <typename T> 00069 struct exact_gcc_2_95< T* > 00070 { 00071 typedef typename mln::internal::exact_<T>::ret E; 00072 typedef E* ret; 00073 static ret run(T* t) 00074 { 00075 return internal::exact_<T>::run(t); 00076 } 00077 }; 00078 00079 template <typename T> 00080 struct exact_gcc_2_95< const T* > 00081 { 00082 typedef typename mln::internal::exact_<T>::ret E; 00083 typedef const E* ret; 00084 static ret run(const T* t) 00085 { 00086 return internal::exact_<T>::run(const_cast<T*>(t)); 00087 } 00088 }; 00089 00090 00091 00092 // For exact(const T&): 00093 00094 template <typename T> 00095 struct exact_const_gcc_2_95 00096 { 00097 typedef typename mln::internal::exact_<T>::ret E; 00098 typedef const E& ret; 00099 static ret run(T& t) 00100 { 00101 return *internal::exact_<T>::run(&t); 00102 } 00103 }; 00104 00105 template <typename T> 00106 struct exact_const_gcc_2_95< const T > 00107 { 00108 typedef typename mln::internal::exact_<T>::ret E; 00109 typedef const E& ret; 00110 static ret run(T& t) 00111 { 00112 return *internal::exact_<T>::run(const_cast<T*>(&t)); 00113 } 00114 }; 00115 00116 template <typename T> 00117 struct exact_const_gcc_2_95< T* > 00118 { 00119 typedef typename mln::internal::exact_<T>::ret E; 00120 typedef E* ret; 00121 static ret run(T* t) 00122 { 00123 return internal::exact_<T>::run(t); 00124 } 00125 }; 00126 00127 template <typename T> 00128 struct exact_const_gcc_2_95< const T*const > 00129 { 00130 typedef typename mln::internal::exact_<T>::ret E; 00131 typedef const E* ret; 00132 static ret run(T* t) 00133 { 00134 return internal::exact_<T>::run(const_cast<T*>(t)); 00135 } 00136 }; 00137 00138 template <typename T> 00139 struct exact_const_gcc_2_95< const T* > 00140 { 00141 typedef typename mln::internal::exact_<T>::ret E; 00142 typedef const E* ret; 00143 static ret run(const T* t) 00144 { 00145 return internal::exact_<T>::run(const_cast<T*>(t)); 00146 } 00147 }; 00148 00149 00150 } // end of namespace mln::internal 00151 00152 00153 00154 template <typename T> 00155 typename internal::exact_gcc_2_95<T>::ret 00156 inline 00157 exact(T& t) 00158 { 00159 return internal::exact_gcc_2_95<T>::run(t); 00160 } 00161 00162 template <typename T> 00163 typename internal::exact_const_gcc_2_95<T>::ret 00164 inline 00165 exact(const T& t) 00166 { 00167 return internal::exact_const_gcc_2_95<T>::run(const_cast<T&>(t)); 00168 } 00169 00170 00171 00172 } // end of namespace mln 00173 00174 #endif // ! MLN_CORE_INTERNAL_EXACT_GCC_2_95_HH