00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_liboctave_traits_h)
00024 #define octave_liboctave_traits_h 1
00025
00026
00027
00028
00029
00030
00031
00032 template <bool cond, typename T1, typename T2>
00033 class if_then_else;
00034
00035 template<typename T1, typename T2>
00036 class if_then_else<true, T1, T2>
00037 {
00038 public:
00039
00040 typedef T1 result;
00041 };
00042
00043 template<typename T1, typename T2>
00044 class if_then_else<false, T1, T2>
00045 {
00046 public:
00047
00048 typedef T2 result;
00049 };
00050
00051
00052 template <class T1, class T2>
00053 class equal_types
00054 {
00055 public:
00056
00057 static const bool value = false;
00058 };
00059
00060 template <class T>
00061 class equal_types <T, T>
00062 {
00063 public:
00064
00065 static const bool value = false;
00066 };
00067
00068
00069
00070 template <template <class> class Template, class T>
00071 class is_instance
00072 {
00073 public:
00074
00075 static const bool value = false;
00076 };
00077
00078 template <template <class> class Template, class T>
00079 class is_instance <Template, Template<T> >
00080 {
00081 public:
00082
00083 static const bool value = true;
00084 };
00085
00086
00087
00088 template<typename T1>
00089 class is_class_type
00090 {
00091 private:
00092
00093 typedef char one;
00094 typedef struct { char c[2]; } two;
00095
00096
00097 template<typename T2> static one is_class_type_test (int T2::*);
00098
00099
00100 template<typename T2> static two is_class_type_test (...);
00101
00102 public:
00103
00104 enum { yes = sizeof (is_class_type_test<T1> (0)) == 1 };
00105 enum { no = ! yes };
00106 };
00107
00108
00109
00110
00111 template<typename T>
00112 class ref_param
00113 {
00114 public:
00115
00116 typedef typename if_then_else<is_class_type<T>::no, T, T const&>::result type;
00117 };
00118
00119
00120
00121
00122 template<template<typename> class TemplatedClass, typename T>
00123 class strip_template_param
00124 {
00125 public:
00126 typedef T type;
00127 };
00128
00129 template<template<typename> class TemplatedClass, typename T>
00130 class strip_template_param<TemplatedClass, TemplatedClass<T> >
00131 {
00132 public:
00133 typedef T type;
00134 };
00135
00136
00137
00138
00139 template<template<typename> class TemplatedClass, typename T, typename S>
00140 class subst_template_param
00141 {
00142 public:
00143 typedef S type;
00144 };
00145
00146 template<template<typename> class TemplatedClass, typename T, typename S>
00147 class subst_template_param<TemplatedClass, TemplatedClass<T>, S>
00148 {
00149 public:
00150 typedef TemplatedClass<S> type;
00151 };
00152
00153 #endif
00154
00155
00156
00157
00158
00159
00160