|
libpsynth 0.2.1
|
00001 00012 /* 00013 * Copyright (C) 2009 Juan Pedro BolĂvar Puente 00014 * 00015 * This program is free software: you can redistribute it and/or modify 00016 * it under the terms of the GNU General Public License as published by 00017 * the Free Software Foundation, either version 3 of the License, or 00018 * (at your option) any later version. 00019 * 00020 * This program is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * You should have received a copy of the GNU General Public License 00026 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00027 * 00028 */ 00029 00030 #ifndef PSYNTH_BASE_UTIL_H_ 00031 #define PSYNTH_BASE_UTIL_H_ 00032 00033 #include <psynth/base/compat.hpp> 00034 #include <boost/utility.hpp> 00035 00036 namespace psynth 00037 { 00038 namespace base 00039 { 00040 00041 template <typename T> 00042 void ignore_unused_variable_warning (T&&) {} 00043 00044 template <template <class, class> class F, typename Y> 00045 struct tpl_bind_snd 00046 { 00047 template <class X> 00048 struct type : public F<X, Y> 00049 {}; 00050 }; 00051 00052 template <template <class, class> class F, typename X> 00053 struct tpl_bind_fst 00054 { 00055 template <class Y> 00056 struct type : public F<X, Y> 00057 {}; 00058 }; 00059 00060 struct nop_ostream {}; 00061 template <typename T> PSYNTH_FORCEINLINE 00062 const nop_ostream& operator<< (const nop_ostream& s, const T&) { return s; } 00063 00069 template <typename Ptr1, typename Ptr2> 00070 bool equal_ptr (Ptr1 a, Ptr2 b) 00071 { 00072 return &*a == &*b; 00073 } 00074 00075 template <typename A> 00076 struct equal_id 00077 { 00078 const A& elem; 00079 00080 equal_id (const A& e) : elem (e) {} 00081 00082 bool operator () (const A& b) const 00083 { 00084 return &elem == &b; 00085 } 00086 }; 00087 00088 template <typename A> 00089 equal_id<A> make_equal_id (const A& e) 00090 { 00091 return equal_id<A> (e); 00092 } 00093 00094 } /* namespace base */ 00095 } /* namespace psynth */ 00096 00097 00098 #endif /* PSYNTH_BASE_UTIL_H_ */
1.7.4