#pragma once #include namespace orange { template struct alignas(Alignment) Swizzle { Array data; // TODO: Deduplicate these constructors... somehow constexpr Swizzle() : data{ } {} constexpr explicit Swizzle(T splat) { Fill(data.begin(), data.end(), splat); } constexpr Swizzle(const T components[Size]) { Copy(&components[0], &components[Size], data.begin()); } }; template struct alignas(Alignment) Swizzle { union { Array data; struct { float x; }; struct { float r; }; }; constexpr Swizzle() : data{ } {} constexpr explicit Swizzle(T splat) { Fill(data.begin(), data.end(), splat); } constexpr Swizzle(const T components[1]) { Copy(&components[0], &components[1], data.begin()); } constexpr Swizzle(const Swizzle& other) = default; }; template struct alignas(Alignment) Swizzle { union { Array data; struct { float x; float y; }; struct { float r; float g; }; }; constexpr Swizzle() : data{ } {} constexpr explicit Swizzle(T splat) { Fill(data.begin(), data.end(), splat); } constexpr Swizzle(const T components[2]) { Copy(&components[0], &components[2], data.begin()); } template constexpr Swizzle(const Args&... args) : data {{ args... }} { static_assert(sizeof...(Args) == 2); } constexpr Swizzle(const Swizzle& other) = default; }; template struct alignas(Alignment) Swizzle { union { Array data; struct { float x; float y; float z; }; struct { float r; float g; float b; }; }; constexpr Swizzle() : data{ } {} constexpr explicit Swizzle(T splat) { Fill(data.begin(), data.end(), splat); } constexpr Swizzle(const T components[3]) { Copy(&components[0], &components[3], data.begin()); } template constexpr Swizzle(const Args&... args) : data {{ args... }} { static_assert(sizeof...(Args) == 3); } constexpr Swizzle(const Swizzle& other) = default; }; template struct alignas(Alignment) Swizzle { union { Array data; struct { float x; float y; float z; float w; }; struct { float r; float g; float b; float a; }; }; constexpr Swizzle() : data{ } {} constexpr explicit Swizzle(T splat) { Fill(data.begin(), data.end(), splat); } constexpr Swizzle(const T components[4]) { Copy(&components[0], &components[4], data.begin()); } template constexpr Swizzle(const Args&... args) : data {{ args... }} { static_assert(sizeof...(Args) == 4); } constexpr Swizzle(const Swizzle& other) = default; }; }