20 #ifndef VC_COMMON_TYPES_H
21 #define VC_COMMON_TYPES_H
23 #ifdef VC_CHECK_ALIGNMENT
43 namespace VectorSpecialInitializerZero {
enum ZEnum {
Zero = 0 }; }
44 namespace VectorSpecialInitializerOne {
enum OEnum {
One = 1 }; }
47 template<
typename V,
size_t Size1,
size_t Size2>
class Memory;
49 # if defined(VC_IMPL_Scalar)
51 template<
typename T>
class Vector;
52 template<
unsigned int VectorSize>
class Mask;
54 #define _Vector Vc::Scalar::Vector
55 # elif defined(VC_IMPL_SSE)
57 template<
typename T>
class Vector;
58 template<
unsigned int VectorSize>
class Mask;
61 #define _Vector Vc::SSE::Vector
62 # elif defined(VC_IMPL_AVX)
64 template<
typename T>
class Vector;
65 template<
unsigned int VectorSize,
size_t RegisterW
idth>
class Mask;
67 #define _Vector Vc::AVX::Vector
69 # error "Sorry, MSVC is a nasty compiler and needs extra care. Please help."
74 template<
bool Test,
typename T =
void>
struct EnableIf {
typedef T Value; };
75 template<
typename T>
struct EnableIf<
false,
T> {};
77 template<
typename T>
struct IsSignedInteger {
enum {
Value = 0 }; };
78 template<>
struct IsSignedInteger<signed char> {
enum {
Value = 1 }; };
79 template<>
struct IsSignedInteger<short> {
enum {
Value = 1 }; };
80 template<>
struct IsSignedInteger<int> {
enum {
Value = 1 }; };
81 template<>
struct IsSignedInteger<long> {
enum {
Value = 1 }; };
82 template<>
struct IsSignedInteger<long long> {
enum {
Value = 1 }; };
84 template<
typename T>
struct IsUnsignedInteger {
enum {
Value = 0 }; };
85 template<>
struct IsUnsignedInteger<unsigned char> {
enum {
Value = 1 }; };
86 template<>
struct IsUnsignedInteger<unsigned short> {
enum {
Value = 1 }; };
87 template<>
struct IsUnsignedInteger<unsigned int> {
enum {
Value = 1 }; };
88 template<>
struct IsUnsignedInteger<unsigned long> {
enum {
Value = 1 }; };
89 template<>
struct IsUnsignedInteger<unsigned long long> {
enum {
Value = 1 }; };
93 template<
typename T>
struct IsReal {
enum {
Value = 0 }; };
94 template<>
struct IsReal<float> {
enum {
Value = 1 }; };
95 template<>
struct IsReal<
double> {
enum {
Value = 1 }; };
97 template<
typename T,
typename U>
struct IsEqualType {
enum {
Value = 0 }; };
98 template<
typename T>
struct IsEqualType<
T,
T> {
enum {
Value = 1 }; };
100 template<
typename T,
typename List0,
typename List1 =
void,
typename List2 =
void,
typename List3 =
void,
typename List4 =
void,
typename List5 =
void,
typename List6 =
void>
101 struct IsInTypelist {
enum {
Value =
false }; };
102 template<
typename T,
typename List1,
typename List2,
typename List3,
typename List4,
typename List5,
typename List6>
struct IsInTypelist<
T,
T, List1, List2, List3, List4, List5, List6> {
enum {
Value =
true }; };
103 template<
typename T,
typename List0,
typename List2,
typename List3,
typename List4,
typename List5,
typename List6>
struct IsInTypelist<
T, List0,
T, List2, List3, List4, List5, List6> {
enum {
Value =
true }; };
104 template<
typename T,
typename List0,
typename List1,
typename List3,
typename List4,
typename List5,
typename List6>
struct IsInTypelist<
T, List0, List1,
T, List3, List4, List5, List6> {
enum {
Value =
true }; };
105 template<
typename T,
typename List0,
typename List1,
typename List2,
typename List4,
typename List5,
typename List6>
struct IsInTypelist<
T, List0, List1, List2,
T, List4, List5, List6> {
enum {
Value =
true }; };
106 template<
typename T,
typename List0,
typename List1,
typename List2,
typename List3,
typename List5,
typename List6>
struct IsInTypelist<
T, List0, List1, List2, List3,
T, List5, List6> {
enum {
Value =
true }; };
107 template<
typename T,
typename List0,
typename List1,
typename List2,
typename List3,
typename List4,
typename List6>
struct IsInTypelist<
T, List0, List1, List2, List3, List4,
T, List6> {
enum {
Value =
true }; };
108 template<
typename T,
typename List0,
typename List1,
typename List2,
typename List3,
typename List4,
typename List5>
struct IsInTypelist<
T, List0, List1, List2, List3, List4, List5,
T> {
enum {
Value =
true }; };
110 template<
typename Arg0,
typename Arg1,
typename T0,
typename T1>
struct IsCombinationOf {
enum {
Value =
false }; };
111 template<
typename Arg0,
typename Arg1>
struct IsCombinationOf<Arg0, Arg1, Arg0, Arg1> {
enum {
Value =
true }; };
112 template<
typename Arg0,
typename Arg1>
struct IsCombinationOf<Arg0, Arg1, Arg1, Arg0> {
enum {
Value =
true }; };
116 struct yes {
char x; };
117 struct no { yes
x,
y; };
120 template<
typename From,
typename To>
struct HasImplicitCast
127 static yes
test(
const To &) {
return yes(); }
129 static yes
test( To) {
return yes(); }
131 static no
test(...) {
return no(); }
135 #pragma warning(suppress : 4257 4267)
137 Value = !!(
sizeof(
test(*static_cast<From *>(0))) ==
sizeof(yes))
140 #if defined(VC_GCC) && VC_GCC < 0x40300
143 template<>
struct HasImplicitCast<float , int> {
enum {
Value =
true }; };
144 template<>
struct HasImplicitCast<
double, int> {
enum {
Value =
true }; };
156 template<
typename T1,
typename T2>
struct HasImplicitCast<_Vector<
T1>,
T2> {
enum {
Value =
false }; };
157 #if defined(VC_IMPL_Scalar)
158 template<
unsigned int VS,
typename T2>
struct HasImplicitCast<
Vc::Scalar::Mask<VS>,
T2> {
enum {
Value =
false }; };
159 template<
unsigned int VS>
struct HasImplicitCast<
Vc::Scalar::Mask<VS>, Vc::Scalar::Mask<VS> > {
enum {
Value =
true }; };
160 #elif defined(VC_IMPL_SSE)
161 template<
unsigned int VS,
typename T2>
struct HasImplicitCast<
Vc::SSE::Mask<VS>,
T2> {
enum {
Value =
false }; };
162 template<
unsigned int VS>
struct HasImplicitCast<
Vc::SSE::Mask<VS>, Vc::SSE::Mask<VS> > {
enum {
Value =
true }; };
163 template<
typename T2>
struct HasImplicitCast<
Vc::SSE::Float8Mask,
T2> {
enum {
Value =
false }; };
164 template<>
struct HasImplicitCast<
Vc::SSE::Float8Mask, Vc::SSE::Float8Mask> {
enum {
Value =
true }; };
165 #elif defined(VC_IMPL_AVX)
166 template<
unsigned int VectorSize,
size_t RegisterW
idth,
typename T2>
struct HasImplicitCast<
Vc::AVX::Mask<VectorSize, RegisterWidth>,
T2> {
enum {
Value =
false }; };
167 template<
unsigned int VectorSize,
size_t RegisterW
idth>
struct HasImplicitCast<
Vc::AVX::Mask<VectorSize, RegisterWidth>, Vc::AVX::Mask<VectorSize, RegisterWidth> > {
enum {
Value =
true }; };
169 template<
typename T>
struct HasImplicitCast<_Vector<
T>, _Vector<
T> > {
enum {
Value =
true }; };
174 template<
typename V,
size_t Size1,
size_t Size2,
typename T2>
struct HasImplicitCast<
Vc::Memory<V, Size1, Size2>,
T2> {
enum {
Value =
false }; };
175 template<
typename V,
size_t Size1,
size_t Size2>
struct HasImplicitCast<
Vc::Memory<V, Size1, Size2>,
Vc::Memory<V, Size1, Size2> > {
enum {
Value =
true }; };
179 template<
typename T>
struct CanConvertToInt :
public HasImplicitCast<T, int> {};
180 template<>
struct CanConvertToInt<bool> {
enum {
Value = 0 }; };
193 typedef HasImplicitCast<TestEnum, short> HasImplicitCastTest0;
194 typedef HasImplicitCast<int *, void *> HasImplicitCastTest1;
195 typedef HasImplicitCast<int *, const void *> HasImplicitCastTest2;
196 typedef HasImplicitCast<const int *, const void *> HasImplicitCastTest3;
197 typedef HasImplicitCast<const int *, int *> HasImplicitCastTest4;
209 #ifndef VC_CHECK_ALIGNMENT
215 if((reinterpret_cast<size_t>(ptr) & ((s ^ (s & (s - 1))) - 1)) != 0) {
216 fprintf(stderr,
"A vector with incorrect alignment has just been created. Look at the stacktrace to find the guilty object.\n");
225 #endif // VC_COMMON_TYPES_H
Namespace for new ROOT classes and functions.
ClassImp(TIterator) Bool_t TIterator return false
Compare two iterator objects.
static Vc_ALWAYS_INLINE void assertCorrectAlignment(const _T *)
A helper class for fixed-size two-dimensional arrays.
#define Vc_ALIGNOF(_TYPE_)
#define VC_STATIC_ASSERT(cond, msg)