00001 /* 00002 Copyright © 2010 yan Verdavaine 00003 00004 This file is part of QExtend. 00005 00006 QExtend is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 any later version. 00010 00011 QExtend is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with QExtend. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef QEXTEND_TEMPLATETOOLS_H 00021 #define QEXTEND_TEMPLATETOOLS_H 00022 namespace QExtend 00023 { 00024 00025 00026 00027 00028 00029 00030 template<typename D, typename B> 00031 class IsDerivedFrom 00032 { 00033 //internal dev not cocumented 00034 class No { }; 00035 class Yes { No no[3]; }; 00036 00037 static Yes Test( B* ); // declared, but not defined 00038 static No Test( ... ); // declared, but not defined 00039 00040 public: 00041 // 00042 static const bool val = sizeof(Test(static_cast<D*>(0))) == sizeof(Yes); 00043 }; 00044 00045 template<typename T, typename Sig> 00046 class has_hello { 00047 class No { }; 00048 class Yes { No no[3]; }; 00049 00050 template <typename U, Sig> struct type_check; 00051 00052 template <typename V> static Yes Test(type_check<V, &V::hello>*); 00053 template <typename > static No Test (...); 00054 public : 00055 static const bool val = sizeof(Test<T>(0)) == sizeof(Yes); 00056 00057 }; 00058 00059 00060 template<typename T, typename Sig> 00061 class has_hello2 { 00062 class No { }; 00063 class Yes { No no[3]; }; 00064 00065 template <typename U, U> struct type_check; 00066 00067 template <typename V> static Yes Test(type_check<Sig V::*, &V::hello>*); 00068 template <typename V> static Yes Test(type_check<Sig, &V::hello>*); 00069 template <typename > static No Test (...); 00070 public : 00071 static const bool val = sizeof(Test<T>(0)) == sizeof(Yes); 00072 00073 }; 00074 00075 00076 00077 00078 00079 } 00080 #endif
© 2000-2025 - www.developpez.com