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
00026
00027
00028
00029
00030
00031 namespace TooN {
00032
00033
00034
00035 template<int Size1, int Size2>
00036 struct SizeMismatch_;
00037
00038
00039 template<int Size>
00040 struct SizeMismatch_<Size,Size>{
00041 static inline void test(int, int){}
00042 };
00043
00044 template<int Size>
00045 struct SizeMismatch_<Dynamic,Size>{
00046 static inline void test(int size1, int size2){
00047 if(size1!=size2){
00048 #ifdef TOON_TEST_INTERNALS
00049 throw Internal::SizeMismatch();
00050 #elif !defined TOON_NDEBUG_SIZE
00051 std::cerr << "TooN Size Mismatch" << std::endl;
00052 std::abort();
00053 #endif
00054 }
00055 }
00056 };
00057
00058 template<int Size>
00059 struct SizeMismatch_<Size,Dynamic>{
00060 static inline void test(int size1, int size2){
00061 if(size1!=size2){
00062 #ifdef TOON_TEST_INTERNALS
00063 throw Internal::SizeMismatch();
00064 #elif !defined TOON_NDEBUG_SIZE
00065 std::cerr << "TooN Size Mismatch" << std::endl;
00066 std::abort();
00067 #endif
00068 }
00069 }
00070 };
00071
00072 template <>
00073 struct SizeMismatch_<Dynamic,Dynamic>{
00074 static inline void test(int size1, int size2){
00075 if(size1!=size2){
00076 #ifdef TOON_TEST_INTERNALS
00077 throw Internal::SizeMismatch();
00078 #elif !defined TOON_NDEBUG_SIZE
00079 std::cerr << "TooN Size Mismatch" << std::endl;
00080 std::abort();
00081 #endif
00082 }
00083 }
00084 };
00085
00086 namespace Internal
00087 {
00088 struct BadSize;
00089 }
00090
00091 template<int Size1, int Size2>
00092 struct SizeMismatch_
00093 {
00094 static inline void test(int, int)
00095 {
00096 #ifdef TOON_TEST_INTERNALS
00097 throw Internal::StaticSizeMismatch();
00098 #else
00099
00100 #endif
00101 }
00102 };
00103
00104 template<int Size1, int Size2>
00105 struct SizeMismatch
00106 {
00107 static inline void test(int s1, int s2)
00108 {
00109 SizeMismatch_< (Size1 == Dynamic || Size1 == Resizable)?Dynamic:Size1,
00110 (Size2 == Dynamic || Size2 == Resizable)?Dynamic:Size2 >::test(s1, s2);
00111 }
00112 };
00113
00114 }