25 struct true_type {
enum { value = 1 }; };
26 struct false_type {
enum { value = 0 }; };
28 template<
bool Condition,
typename Then,
typename Else>
29 struct conditional {
typedef Then type; };
31 template<
typename Then,
typename Else>
32 struct conditional <false, Then, Else> {
typedef Else type; };
34 template<
typename T,
typename U>
struct is_same {
enum { value = 0 }; };
35 template<
typename T>
struct is_same<T,T> {
enum { value = 1 }; };
37 template<
typename T>
struct remove_reference {
typedef T type; };
38 template<
typename T>
struct remove_reference<T&> {
typedef T type; };
40 template<
typename T>
struct remove_pointer {
typedef T type; };
41 template<
typename T>
struct remove_pointer<T*> {
typedef T type; };
42 template<
typename T>
struct remove_pointer<T*
const> {
typedef T type; };
44 template <
class T>
struct remove_const {
typedef T type; };
45 template <
class T>
struct remove_const<const T> {
typedef T type; };
46 template <
class T>
struct remove_const<const T[]> {
typedef T type[]; };
47 template <
class T,
unsigned int Size>
struct remove_const<const T[Size]> {
typedef T type[Size]; };
49 template<
typename T>
struct remove_all {
typedef T type; };
50 template<
typename T>
struct remove_all<const T> {
typedef typename remove_all<T>::type type; };
51 template<
typename T>
struct remove_all<T const&> {
typedef typename remove_all<T>::type type; };
52 template<
typename T>
struct remove_all<T&> {
typedef typename remove_all<T>::type type; };
53 template<
typename T>
struct remove_all<T const*> {
typedef typename remove_all<T>::type type; };
54 template<
typename T>
struct remove_all<T*> {
typedef typename remove_all<T>::type type; };
56 template<
typename T>
struct is_arithmetic {
enum { value =
false }; };
57 template<>
struct is_arithmetic<float> {
enum { value =
true }; };
58 template<>
struct is_arithmetic<double> {
enum { value =
true }; };
59 template<>
struct is_arithmetic<long double> {
enum { value =
true }; };
60 template<>
struct is_arithmetic<bool> {
enum { value =
true }; };
61 template<>
struct is_arithmetic<char> {
enum { value =
true }; };
62 template<>
struct is_arithmetic<signed char> {
enum { value =
true }; };
63 template<>
struct is_arithmetic<unsigned char> {
enum { value =
true }; };
64 template<>
struct is_arithmetic<signed short> {
enum { value =
true }; };
65 template<>
struct is_arithmetic<unsigned short>{
enum { value =
true }; };
66 template<>
struct is_arithmetic<signed int> {
enum { value =
true }; };
67 template<>
struct is_arithmetic<unsigned int> {
enum { value =
true }; };
68 template<>
struct is_arithmetic<signed long> {
enum { value =
true }; };
69 template<>
struct is_arithmetic<unsigned long> {
enum { value =
true }; };
71 template <
typename T>
struct add_const {
typedef const T type; };
72 template <
typename T>
struct add_const<T&> {
typedef T& type; };
74 template <
typename T>
struct is_const {
enum { value = 0 }; };
75 template <
typename T>
struct is_const<T const> {
enum { value = 1 }; };
77 template<
typename T>
struct add_const_on_value_type {
typedef const T type; };
78 template<
typename T>
struct add_const_on_value_type<T&> {
typedef T
const& type; };
79 template<
typename T>
struct add_const_on_value_type<T*> {
typedef T
const* type; };
80 template<
typename T>
struct add_const_on_value_type<T*
const> {
typedef T
const*
const type; };
81 template<
typename T>
struct add_const_on_value_type<T const*
const> {
typedef T
const*
const type; };
86 template<
bool Condition,
typename T>
struct enable_if;
88 template<
typename T>
struct enable_if<true,T>
98 noncopyable(
const noncopyable&);
99 const noncopyable& operator=(
const noncopyable&);
113 template<
typename T>
struct result_of {};
115 struct has_none {
int a[1];};
116 struct has_std_result_type {
int a[2];};
117 struct has_tr1_result {
int a[3];};
119 template<
typename Func,
typename ArgType,
int SizeOf=sizeof(has_none)>
120 struct unary_result_of_select {
typedef ArgType type;};
122 template<
typename Func,
typename ArgType>
123 struct unary_result_of_select<Func, ArgType, sizeof(has_std_result_type)> {
typedef typename Func::result_type type;};
125 template<
typename Func,
typename ArgType>
126 struct unary_result_of_select<Func, ArgType, sizeof(has_tr1_result)> {
typedef typename Func::template result<Func(ArgType)>::type type;};
128 template<
typename Func,
typename ArgType>
129 struct result_of<Func(ArgType)> {
131 static has_std_result_type testFunctor(T
const *,
typename T::result_type
const * = 0);
133 static has_tr1_result testFunctor(T
const *,
typename T::template result<T(ArgType)>::type
const * = 0);
134 static has_none testFunctor(...);
137 enum {FunctorType =
sizeof(testFunctor(static_cast<Func*>(0)))};
138 typedef typename unary_result_of_select<Func, ArgType, FunctorType>::type type;
141 template<
typename Func,
typename ArgType0,
typename ArgType1,
int SizeOf=sizeof(has_none)>
142 struct binary_result_of_select {
typedef ArgType0 type;};
144 template<
typename Func,
typename ArgType0,
typename ArgType1>
145 struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_std_result_type)>
146 {
typedef typename Func::result_type type;};
148 template<
typename Func,
typename ArgType0,
typename ArgType1>
149 struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_tr1_result)>
150 {
typedef typename Func::template result<Func(ArgType0,ArgType1)>::type type;};
152 template<
typename Func,
typename ArgType0,
typename ArgType1>
153 struct result_of<Func(ArgType0,ArgType1)> {
155 static has_std_result_type testFunctor(T
const *,
typename T::result_type
const * = 0);
157 static has_tr1_result testFunctor(T
const *,
typename T::template result<T(ArgType0,ArgType1)>::type
const * = 0);
158 static has_none testFunctor(...);
161 enum {FunctorType =
sizeof(testFunctor(static_cast<Func*>(0)))};
162 typedef typename binary_result_of_select<Func, ArgType0, ArgType1, FunctorType>::type type;
170 int SupX = ((Y==1) ? 1 : Y/2),
171 bool Done = ((SupX-InfX)<=1 ?
true : ((SupX*SupX <= Y) && ((SupX+1)*(SupX+1) > Y))) >
176 MidX = (InfX+SupX)/2,
177 TakeInf = MidX*MidX > Y ? 1 : 0,
178 NewInf =
int(TakeInf) ? InfX : int(MidX),
179 NewSup = int(TakeInf) ? int(MidX) : SupX
182 enum { ret = meta_sqrt<Y,NewInf,NewSup>::ret };
185 template<
int Y,
int InfX,
int SupX>
186 class meta_sqrt<Y, InfX, SupX, true> {
public:
enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };
189 template<
typename T,
typename U>
struct scalar_product_traits
191 enum { Defined = 0 };
194 template<
typename T>
struct scalar_product_traits<T,T>
200 typedef T ReturnType;
203 template<
typename T>
struct scalar_product_traits<T,std::complex<T> >
209 typedef std::complex<T> ReturnType;
212 template<
typename T>
struct scalar_product_traits<std::complex<T>, T>
218 typedef std::complex<T> ReturnType;
227 template<
typename T>
struct is_diagonal
228 {
enum { ret =
false }; };
230 template<
typename T>
struct is_diagonal<DiagonalBase<T> >
231 {
enum { ret =
true }; };
233 template<
typename T>
struct is_diagonal<DiagonalWrapper<T> >
234 {
enum { ret =
true }; };
236 template<
typename T,
int S>
struct is_diagonal<DiagonalMatrix<T,S> >
237 {
enum { ret =
true }; };
243 #endif // EIGEN_META_H