glm/test/bug/bug_ms_vec_static.cpp

60 lines
1.0 KiB
C++
Raw Normal View History

2017-01-04 22:29:37 +00:00
template<typename T> struct vec2;
2017-01-04 22:19:48 +00:00
struct _swizzle_base0
{
char _buffer[1];
};
2017-01-04 22:30:44 +00:00
template<int E0, int E1, int E2, int E3>
struct _swizzle_base1 : public _swizzle_base0
2017-01-04 22:19:48 +00:00
{
};
2017-01-04 22:30:44 +00:00
template<int E0, int E1>
struct _swizzle_base1<E0,E1,-1,-2> : public _swizzle_base0
2017-01-04 22:19:48 +00:00
{
2017-01-04 22:28:07 +00:00
2017-01-04 22:19:48 +00:00
};
2017-01-04 22:30:44 +00:00
template<int E0, int E1, int E2, int E3, int DUPLICATE_ELEMENTS>
struct _swizzle_base2 : public _swizzle_base1<E0,E1,E2,E3>
2017-01-04 22:19:48 +00:00
{
};
2017-01-04 22:30:44 +00:00
template<int E0, int E1, int E2, int E3>
struct _swizzle_base2<E0,E1,E2,E3, 1> : public _swizzle_base1<E0,E1,E2,E3>
2017-01-04 22:19:48 +00:00
{
};
2017-01-04 22:30:44 +00:00
template<int E0, int E1, int E2, int E3>
struct _swizzle : public _swizzle_base2<E0, E1, E2, E3, (E0 == E1 || E0 == E2 || E0 == E3 || E1 == E2 || E1 == E3 || E2 == E3)>
2017-01-04 22:19:48 +00:00
{
};
2017-01-04 22:29:37 +00:00
template<typename T>
2017-01-04 22:19:48 +00:00
struct vec2
{
constexpr vec2(T x, T y) :
x(x), y(y)
{}
union
{
2017-01-04 22:28:07 +00:00
struct { T x, y; };
2017-01-04 22:30:44 +00:00
struct { _swizzle<0,0,-1,-2> xx; };
2017-01-04 22:19:48 +00:00
};
};
2017-01-04 22:29:37 +00:00
typedef vec2<float> float2;
2016-09-25 08:29:08 +00:00
// Visual C++ has a bug generating the error: fatal error C1001: An internal error has occurred in the compiler.
2017-01-04 22:19:48 +00:00
float2 const Bar(1.f, 1.f);
2016-09-25 08:29:08 +00:00
int main()
{
2016-09-25 08:35:30 +00:00
return 0;
2016-09-25 08:29:08 +00:00
}