00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027 #ifndef SHUTILITY_HPP
00028 #define SHUTILITY_HPP
00029
00034 #include <iosfwd>
00035 #include <map>
00036 #include "ShDllExport.hpp"
00037
00038 namespace SH {
00039
00041 SH_DLLEXPORT
00042 std::ostream& shPrintIndent(std::ostream& out, int indent);
00043
00047 template<bool B> struct ShCompileTimeChecker
00048 {
00049 ShCompileTimeChecker(...);
00050 };
00051 template<> struct ShCompileTimeChecker<false> {
00052 };
00053
00054 #define SH_STATIC_CHECK(expr, msg) \
00055 { \
00056 class SH_ERROR_##msg {} y; \
00057 (void)sizeof(ShCompileTimeChecker<(expr)>(y));\
00058 }
00059
00060 struct
00061 SH_DLLEXPORT ShIgnore {
00062 template<typename T>
00063 T& operator&(T& other) { return other; }
00064 };
00065
00067 template<bool B, typename T1, typename T2>
00068 struct SelectType;
00069
00070 template<typename T1, typename T2>
00071 struct SelectType<true, T1, T2> {
00072 typedef T1 type;
00073 };
00074
00075 template<typename T1, typename T2>
00076 struct SelectType<false, T1, T2> {
00077 typedef T2 type;
00078 };
00079
00081 template<typename T1, typename T2>
00082 struct MatchType {
00083 static const bool matches = false;
00084 };
00085
00086 template<typename T>
00087 struct MatchType<T, T> {
00088 static const bool matches = true;
00089 };
00090
00091 template<typename T, typename T1, typename T2>
00092 struct MatchEitherType {
00093 static const bool matches = MatchType<T1, T>::matches ||
00094 MatchType<T2, T>::matches;
00095 };
00096
00108 template<typename T, template<typename A> class B>
00109 struct MatchTemplateType {
00110 static const bool matches = false;
00111 };
00112
00113 template<typename T, template<typename A> class B>
00114 struct MatchTemplateType<B<T>, B> {
00115 static const bool matches = true;
00116 };
00117
00119 template<typename T, template<typename A> class B>
00120 struct TemplateParameterType;
00121
00122 template<typename T, template<typename A> class B>
00123 struct TemplateParameterType<B<T>, B> {
00124 typedef T type;
00125 };
00126
00127 }
00128
00129 #endif