Help us understand the problem. What is going on with this article?

XMINT君が面倒くさい!!

初めに

 前回の続きです。リア友にXMINT版とXMUINT版も出してくれと言われたので、記事を上げることにしました。

早速

XMINT

XMINT_Helper.h
#pragma once

#include <DirectXMath.h>
#include <initializer_list>

//-------------------------------------------------------------------------------------------------------------
//. XMINT4系
//-------------------------------------------------------------------------------------------------------------

static inline void operator+= (DirectX::XMINT4& v1, const DirectX::XMINT4& v2)
{
    v1.x += v2.x;
    v1.y += v2.y;
    v1.z += v2.z;
    v1.w += v2.w;
}

static inline void operator-= (DirectX::XMINT4& v1, const DirectX::XMINT4& v2)
{
    v1.x -= v2.x;
    v1.y -= v2.y;
    v1.z -= v2.z;
    v1.w -= v2.w;
}

static inline void operator/= (DirectX::XMINT4& v1, const DirectX::XMINT4& v2)
{
    v1.x /= v2.x;
    v1.y /= v2.y;
    v1.z /= v2.z;
    v1.w /= v2.w;
}

static inline void operator*= (DirectX::XMINT4& v1, const DirectX::XMINT4& v2)
{
    v1.x *= v2.x;
    v1.y *= v2.y;
    v1.z *= v2.z;
    v1.w *= v2.w;
}

static inline void operator%= (DirectX::XMINT4& v1, const DirectX::XMINT4& v2)
{
    v1.x %= v2.x;
    v1.y %= v2.y;
    v1.z %= v2.z;
    v1.w %= v2.w;
}

_NODISCARD static inline constexpr auto operator+ (const DirectX::XMINT4& v1, const DirectX::XMINT4& v2)
{
    return DirectX::XMINT4{ v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w };
}

_NODISCARD static inline constexpr auto operator- (const DirectX::XMINT4& v1, const DirectX::XMINT4& v2)
{
    return DirectX::XMINT4{ v1.x - v2.x, v1.y - v2.y, v1.z - v2.z, v1.w - v2.w };
}

_NODISCARD static inline constexpr auto operator* (const DirectX::XMINT4& v1, const DirectX::XMINT4& v2)
{
    return DirectX::XMINT4{ v1.x * v2.x, v1.y * v2.y, v1.z * v2.z, v1.w * v2.w };
}

_NODISCARD static inline constexpr auto operator/ (const DirectX::XMINT4& v1, const DirectX::XMINT4& v2)
{
    return DirectX::XMINT4{ v1.x / v2.x, v1.y / v2.y, v1.z / v2.z, v1.w / v2.w };
}

_NODISCARD static inline constexpr auto operator% (const DirectX::XMINT4& v1, const DirectX::XMINT4& v2)
{
    return DirectX::XMINT4{ (v1.x % v2.x), (v1.y % v2.y), (v1.z % v2.z), (v1.w % v2.w) };
}

static inline void operator+= (DirectX::XMINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x += *itr;
    itr++;
    v1.y += *itr;
    itr++;
    v1.z += *itr;
    itr++;
    v1.w += *itr;
}

static inline void operator-= (DirectX::XMINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x -= *itr;
    itr++;
    v1.y -= *itr;
    itr++;
    v1.z -= *itr;
    itr++;
    v1.w -= *itr;
}

static inline void operator/= (DirectX::XMINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x /= *itr;
    itr++;
    v1.y /= *itr;
    itr++;
    v1.z /= *itr;
    itr++;
    v1.w /= *itr;
}

static inline void operator*= (DirectX::XMINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x *= *itr;
    itr++;
    v1.y *= *itr;
    itr++;
    v1.z *= *itr;
    itr++;
    v1.w *= *itr;
}

static inline void operator%= (DirectX::XMINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x %= *itr;
    itr++;
    v1.y %= *itr;
    itr++;
    v1.z %= *itr;
    itr++;
    v1.w %= *itr;
}

_NODISCARD static inline auto operator+ (const DirectX::XMINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    DirectX::XMINT4 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x += *itr;
    itr++;
    temp.y += *itr;
    itr++;
    temp.z += *itr;
    itr++;
    temp.w += *itr;

    return temp;
}

_NODISCARD static inline auto operator- (const DirectX::XMINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    DirectX::XMINT4 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x -= *itr;
    itr++;
    temp.y -= *itr;
    itr++;
    temp.z -= *itr;
    itr++;
    temp.w -= *itr;

    return temp;
}

_NODISCARD static inline auto operator* (const DirectX::XMINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    DirectX::XMINT4 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x *= *itr;
    itr++;
    temp.y *= *itr;
    itr++;
    temp.z *= *itr;
    itr++;
    temp.w *= *itr;

    return temp;
}

_NODISCARD static inline auto operator/ (const DirectX::XMINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    DirectX::XMINT4 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x /= *itr;
    itr++;
    temp.y /= *itr;
    itr++;
    temp.z /= *itr;
    itr++;
    temp.w /= *itr;

    return temp;
}

_NODISCARD static inline auto operator% (const DirectX::XMINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    DirectX::XMINT4 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x %= *itr;
    itr++;
    temp.y %= *itr;
    itr++;
    temp.z %= *itr;
    itr++;
    temp.w %= *itr;

    return temp;
}

static inline void operator+= (DirectX::XMINT4& v1, const int num)
{
    v1.x += num;
    v1.y += num;
    v1.z += num;
    v1.w += num;
}

static inline void operator-= (DirectX::XMINT4& v1, const int num)
{
    v1.x -= num;
    v1.y -= num;
    v1.z -= num;
    v1.w -= num;
}

static inline void operator/= (DirectX::XMINT4& v1, const int num)
{
    v1.x /= num;
    v1.y /= num;
    v1.z /= num;
    v1.w /= num;
}

static inline void operator*= (DirectX::XMINT4& v1, const int num)
{
    v1.x *= num;
    v1.y *= num;
    v1.z *= num;
    v1.w *= num;
}

static inline void operator%= (DirectX::XMINT4& v1, const int num)
{
    v1.x %= num;
    v1.y %= num;
    v1.z %= num;
    v1.w %= num;
}

_NODISCARD static inline constexpr auto operator+ (const DirectX::XMINT4& v1, const int num)
{
    return DirectX::XMINT4{ v1.x + num, v1.y + num, v1.z + num, v1.w + num };
}

_NODISCARD static inline constexpr auto operator- (const DirectX::XMINT4& v1, const int num)
{
    return DirectX::XMINT4{ v1.x - num, v1.y - num, v1.z - num, v1.w - num };
}

_NODISCARD static inline constexpr auto operator* (const DirectX::XMINT4& v1, const int num)
{
    return DirectX::XMINT4{ v1.x * num, v1.y * num, v1.z * num, v1.w * num };
}

_NODISCARD static inline constexpr auto operator/ (const DirectX::XMINT4& v1, const int num)
{
    return DirectX::XMINT4{ v1.x / num, v1.y / num, v1.z / num, v1.w / num };
}

_NODISCARD static inline constexpr auto operator% (const DirectX::XMINT4& v1, const int num)
{
    return DirectX::XMINT4{ (v1.x % num), (v1.y % num), (v1.z % num), (v1.w % num) };
}

_NODISCARD static inline constexpr bool operator== (const DirectX::XMINT4& v1, const DirectX::XMINT4& v2)
{
    return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w);
}

_NODISCARD static inline constexpr bool operator!= (const DirectX::XMINT4& v1, const DirectX::XMINT4& v2)
{
    return !((v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w));
}

//-------------------------------------------------------------------------------------------------------------
//. XMINT3系
//-------------------------------------------------------------------------------------------------------------

static inline void operator+= (DirectX::XMINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x += *itr;
    itr++;
    v1.y += *itr;
    itr++;
    v1.z += *itr;
}

static inline void operator-= (DirectX::XMINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x -= *itr;
    itr++;
    v1.y -= *itr;
    itr++;
    v1.z -= *itr;
}

static inline void operator/= (DirectX::XMINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x /= *itr;
    itr++;
    v1.y /= *itr;
    itr++;
    v1.z /= *itr;
}

static inline void operator*= (DirectX::XMINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x *= *itr;
    itr++;
    v1.y *= *itr;
    itr++;
    v1.z *= *itr;
}

static inline void operator%= (DirectX::XMINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x *= *itr;
    itr++;
    v1.y *= *itr;
    itr++;
    v1.z *= *itr;
}

_NODISCARD static inline auto operator+ (const DirectX::XMINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    DirectX::XMINT3 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x += *itr;
    itr++;
    temp.y += *itr;
    itr++;
    temp.z += *itr;

    return temp;
}

_NODISCARD static inline auto operator- (const DirectX::XMINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    DirectX::XMINT3 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x -= *itr;
    itr++;
    temp.y -= *itr;
    itr++;
    temp.z -= *itr;

    return temp;
}

_NODISCARD static inline auto operator* (const DirectX::XMINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    DirectX::XMINT3 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x *= *itr;
    itr++;
    temp.y *= *itr;
    itr++;
    temp.z *= *itr;

    return temp;
}

_NODISCARD static inline auto operator/ (const DirectX::XMINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    DirectX::XMINT3 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x /= *itr;
    itr++;
    temp.y /= *itr;
    itr++;
    temp.z /= *itr;

    return temp;
}

_NODISCARD static inline auto operator% (const DirectX::XMINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    DirectX::XMINT3 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x *= *itr;
    itr++;
    temp.y *= *itr;
    itr++;
    temp.z *= *itr;

    return temp;
}

static inline void operator+= (DirectX::XMINT3& v1, const DirectX::XMINT3& v2)
{
    v1.x += v2.x;
    v1.y += v2.y;
    v1.z += v2.z;
}

static inline void operator-= (DirectX::XMINT3& v1, const DirectX::XMINT3& v2)
{
    v1.x -= v2.x;
    v1.y -= v2.y;
    v1.z -= v2.z;
}

static inline void operator*= (DirectX::XMINT3& v1, const DirectX::XMINT3& v2)
{
    v1.x *= v2.x;
    v1.y *= v2.y;
    v1.z *= v2.z;
}

static inline void operator/= (DirectX::XMINT3& v1, const DirectX::XMINT3& v2)
{
    v1.x /= v2.x;
    v1.y /= v2.y;
    v1.z /= v2.z;
}

static inline void operator%= (DirectX::XMINT3& v1, const DirectX::XMINT3& v2)
{
    v1.x %= v2.x;
    v1.y %= v2.y;
    v1.z %= v2.z;
}

_NODISCARD static inline constexpr auto operator+ (const DirectX::XMINT3& v1, const DirectX::XMINT3& v2)
{
    return DirectX::XMINT3{ v1.x + v2.x, v1.y + v2.y, v1.z + v2.z };
}

_NODISCARD static inline constexpr auto operator- (const DirectX::XMINT3& v1, const DirectX::XMINT3& v2)
{
    return DirectX::XMINT3{ v1.x - v2.x, v1.y - v2.y, v1.z - v2.z };
}

_NODISCARD static inline constexpr auto operator* (const DirectX::XMINT3& v1, const DirectX::XMINT3& v2)
{
    return DirectX::XMINT3{ v1.x * v2.x, v1.y * v2.y, v1.z * v2.z };
}

_NODISCARD static inline constexpr auto operator/ (const DirectX::XMINT3& v1, const DirectX::XMINT3& v2)
{
    return DirectX::XMINT3{ v1.x / v2.x, v1.y / v2.y, v1.z / v2.z };
}

_NODISCARD static inline constexpr auto operator% (const DirectX::XMINT3& v1, const DirectX::XMINT3& v2)
{
    return DirectX::XMINT3{ (v1.x % v2.x), (v1.y % v2.y), (v1.z % v2.z) };
}

static inline void operator+= (DirectX::XMINT3& v1, const int num)
{
    v1.x += num;
    v1.y += num;
    v1.z += num;
}

static inline void operator-= (DirectX::XMINT3& v1, const int num)
{
    v1.x -= num;
    v1.y -= num;
    v1.z -= num;
}

static inline void operator/= (DirectX::XMINT3& v1, const int num)
{
    v1.x /= num;
    v1.y /= num;
    v1.z /= num;
}

static inline void operator*= (DirectX::XMINT3& v1, const int num)
{
    v1.x *= num;
    v1.y *= num;
    v1.z *= num;
}

static inline void operator%= (DirectX::XMINT3& v1, const int num)
{
    v1.x %= num;
    v1.y %= num;
    v1.z %= num;
}

_NODISCARD static inline constexpr auto operator+ (const DirectX::XMINT3& v1, const int num)
{
    return DirectX::XMINT3{ v1.x + num, v1.y + num, v1.z + num };
}

_NODISCARD static inline constexpr auto operator- (const DirectX::XMINT3& v1, const int num)
{
    return DirectX::XMINT3{ v1.x - num, v1.y - num, v1.z - num };
}

_NODISCARD static inline constexpr auto operator* (const DirectX::XMINT3& v1, const int num)
{
    return DirectX::XMINT3{ v1.x * num, v1.y * num, v1.z * num };
}

_NODISCARD static inline constexpr auto operator% (const DirectX::XMINT3& v1, const int num)
{
    return DirectX::XMINT3{ (v1.x % num), (v1.y % num), (v1.z % num) };
}

_NODISCARD static inline constexpr auto operator/ (const DirectX::XMINT3& v1, const int num)
{
    return DirectX::XMINT3{ v1.x / num, v1.y / num, v1.z / num };
}

_NODISCARD static inline constexpr bool operator== (const DirectX::XMINT3& v1, const DirectX::XMINT3& v2)
{
    return ((v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z));
}

_NODISCARD static inline constexpr bool operator!= (const DirectX::XMINT3& v1, const DirectX::XMINT3& v2)
{
    return !((v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z));
}

//-------------------------------------------------------------------------------------------------------------
//. XMINT2系
//-------------------------------------------------------------------------------------------------------------

static inline void operator+= (DirectX::XMINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x += *itr;
    itr++;
    v1.y += *itr;
}

static inline void operator-= (DirectX::XMINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x -= *itr;
    itr++;
    v1.y -= *itr;
}

static inline void operator/= (DirectX::XMINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x /= *itr;
    itr++;
    v1.y /= *itr;
}

static inline void operator*= (DirectX::XMINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x *= *itr;
    itr++;
    v1.y *= *itr;
}

static inline void operator%= (DirectX::XMINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x %= *itr;
    itr++;
    v1.y %= *itr;
}

_NODISCARD static inline auto operator+ (const DirectX::XMINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    DirectX::XMINT2 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x += *itr;
    itr++;
    temp.y += *itr;

    return temp;
}

_NODISCARD static inline auto operator- (const DirectX::XMINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    DirectX::XMINT2 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x -= *itr;
    itr++;
    temp.y -= *itr;

    return temp;
}

_NODISCARD static inline auto operator* (const DirectX::XMINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    DirectX::XMINT2 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x *= *itr;
    itr++;
    temp.y *= *itr;

    return temp;
}

_NODISCARD static inline auto operator/ (const DirectX::XMINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    DirectX::XMINT2 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x /= *itr;
    itr++;
    temp.y /= *itr;

    return temp;
}

_NODISCARD static inline auto operator% (const DirectX::XMINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    DirectX::XMINT2 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x %= *itr;
    itr++;
    temp.y %= *itr;

    return temp;
}

static inline void operator+= (DirectX::XMINT2& v1, const DirectX::XMINT2& v2)
{
    v1.x += v2.x;
    v1.y += v2.y;
}

static inline void operator-= (DirectX::XMINT2& v1, const DirectX::XMINT2& v2)
{
    v1.x -= v2.x;
    v1.y -= v2.y;
}

static inline void operator/= (DirectX::XMINT2& v1, const DirectX::XMINT2& v2)
{
    v1.x /= v2.x;
    v1.y /= v2.y;
}

static inline void operator*= (DirectX::XMINT2& v1, const DirectX::XMINT2& v2)
{
    v1.x *= v2.x;
    v1.y *= v2.y;
}

static inline void operator%= (DirectX::XMINT2& v1, const DirectX::XMINT2& v2)
{
    v1.x %= v2.x;
    v1.y %= v2.y;
}

_NODISCARD static inline constexpr auto operator+ (const DirectX::XMINT2& v1, const DirectX::XMINT2& v2)
{
    return DirectX::XMINT2{ v1.x + v2.x, v1.y + v2.y };
}

_NODISCARD static inline constexpr auto operator- (const DirectX::XMINT2& v1, const DirectX::XMINT2& v2)
{
    return DirectX::XMINT2{ v1.x - v2.x, v1.y - v2.y };
}

_NODISCARD static inline constexpr auto operator* (const DirectX::XMINT2& v1, const DirectX::XMINT2& v2)
{
    return DirectX::XMINT2{ v1.x * v2.x, v1.y * v2.y };
}

_NODISCARD static inline constexpr auto operator/ (const DirectX::XMINT2& v1, const DirectX::XMINT2& v2)
{
    return DirectX::XMINT2{ v1.x / v2.x, v1.y / v2.y };
}

_NODISCARD static inline constexpr auto operator% (const DirectX::XMINT2& v1, const DirectX::XMINT2& v2)
{
    return DirectX::XMINT2{ (v1.x % v2.x), (v1.y % v2.y) };
}

static inline void operator+= (DirectX::XMINT2& v1, const int num)
{
    v1.x += num;
    v1.y += num;
}

static inline void operator-= (DirectX::XMINT2& v1, const int num)
{
    v1.x -= num;
    v1.y -= num;
}

static inline void operator/= (DirectX::XMINT2& v1, const int num)
{
    v1.x /= num;
    v1.y /= num;
}

static inline void operator*= (DirectX::XMINT2& v1, const int num)
{
    v1.x *= num;
    v1.y *= num;
}

static inline void operator%= (DirectX::XMINT2& v1, const int num)
{
    v1.x %= num;
    v1.y %= num;
}

_NODISCARD static inline constexpr auto operator+ (const DirectX::XMINT2& v1, const int num)
{
    return DirectX::XMINT2{ v1.x + num, v1.y + num };
}

_NODISCARD static inline constexpr auto operator- (const DirectX::XMINT2& v1, const int num)
{
    return DirectX::XMINT2{ v1.x - num, v1.y - num };
}

_NODISCARD static inline constexpr auto operator* (const DirectX::XMINT2& v1, const int num)
{
    return DirectX::XMINT2{ v1.x * num, v1.y * num };
}

_NODISCARD static inline constexpr auto operator/ (const DirectX::XMINT2& v1, const int num)
{
    return DirectX::XMINT2{ v1.x / num, v1.y / num };
}

_NODISCARD static inline constexpr auto operator% (const DirectX::XMINT2& v1, const int num)
{
    return DirectX::XMINT2{ (v1.x % num), (v1.y % num) };
}

_NODISCARD static inline constexpr bool operator== (const DirectX::XMINT2& v1, const DirectX::XMINT2& v2)
{
    return ((v1.x == v2.x) && (v1.y == v2.y));
}

_NODISCARD static inline constexpr bool operator!= (const DirectX::XMINT2& v1, const DirectX::XMINT2& v2)
{
    return !((v1.x == v2.x) && (v1.y == v2.y));
}

//-------------------------------------------------------------------------------------------------------------
// 特殊変換関数
//-------------------------------------------------------------------------------------------------------------

inline namespace XmintHelpter
{
    // 型上げ-----------------------------------------------------------------------------------------------

    _NODISCARD static inline auto RaiseToXMint4(const DirectX::XMINT3& vec, const int w_component = 0.f)
    {
        return DirectX::XMINT4{ vec.x, vec.y, vec.z, w_component };
    }

    _NODISCARD static inline auto RaiseToXMint4(const DirectX::XMINT2& vec, const int z_component = 0.f, const int w_component = 0.f)
    {
        return DirectX::XMINT4{ vec.x, vec.y, z_component, w_component };
    }

    _NODISCARD static inline auto RaiseToXMINT3(const DirectX::XMINT2& vec, const int z_component = 0.f)
    {
        return DirectX::XMINT3{ vec.x, vec.y, z_component };
    }

    // 型下げ-----------------------------------------------------------------------------------------------

    // W, Z成分が切り捨てられる
    _NODISCARD static inline auto LowerToXMint2(const DirectX::XMINT4& vec)
    {
        return DirectX::XMINT2{ vec.x, vec.y };
    }

    // Z成分が切り捨てられる
    _NODISCARD static inline auto LowerToXMint2(const DirectX::XMINT3& vec)
    {
        return DirectX::XMINT2{ vec.x, vec.y };
    }

    // W成分が切り捨てられる
    _NODISCARD static inline auto LowerToXMINT3(const DirectX::XMINT4& vec)
    {
        return DirectX::XMINT3{ vec.x, vec.y, vec.z };
    }
}

XMUINT

XMUINT_Helper.h
#pragma once

#include <DirectXMath.h>
#include <initializer_list>

//-------------------------------------------------------------------------------------------------------------
//. XUMINT4系
//-------------------------------------------------------------------------------------------------------------

static inline void operator+= (DirectX::XMUINT4& v1, const DirectX::XMUINT4& v2)
{
    v1.x += v2.x;
    v1.y += v2.y;
    v1.z += v2.z;
    v1.w += v2.w;
}

static inline void operator-= (DirectX::XMUINT4& v1, const DirectX::XMUINT4& v2)
{
    v1.x -= v2.x;
    v1.y -= v2.y;
    v1.z -= v2.z;
    v1.w -= v2.w;
}

static inline void operator/= (DirectX::XMUINT4& v1, const DirectX::XMUINT4& v2)
{
    v1.x /= v2.x;
    v1.y /= v2.y;
    v1.z /= v2.z;
    v1.w /= v2.w;
}

static inline void operator*= (DirectX::XMUINT4& v1, const DirectX::XMUINT4& v2)
{
    v1.x *= v2.x;
    v1.y *= v2.y;
    v1.z *= v2.z;
    v1.w *= v2.w;
}

static inline void operator%= (DirectX::XMUINT4& v1, const DirectX::XMUINT4& v2)
{
    v1.x %= v2.x;
    v1.y %= v2.y;
    v1.z %= v2.z;
    v1.w %= v2.w;
}

_NODISCARD static inline constexpr auto operator+ (const DirectX::XMUINT4& v1, const DirectX::XMUINT4& v2)
{
    return DirectX::XMUINT4{ v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w };
}

_NODISCARD static inline constexpr auto operator- (const DirectX::XMUINT4& v1, const DirectX::XMUINT4& v2)
{
    return DirectX::XMUINT4{ v1.x - v2.x, v1.y - v2.y, v1.z - v2.z, v1.w - v2.w };
}

_NODISCARD static inline constexpr auto operator* (const DirectX::XMUINT4& v1, const DirectX::XMUINT4& v2)
{
    return DirectX::XMUINT4{ v1.x * v2.x, v1.y * v2.y, v1.z * v2.z, v1.w * v2.w };
}

_NODISCARD static inline constexpr auto operator/ (const DirectX::XMUINT4& v1, const DirectX::XMUINT4& v2)
{
    return DirectX::XMUINT4{ v1.x / v2.x, v1.y / v2.y, v1.z / v2.z, v1.w / v2.w };
}

_NODISCARD static inline constexpr auto operator% (const DirectX::XMUINT4& v1, const DirectX::XMUINT4& v2)
{
    return DirectX::XMUINT4{ (v1.x % v2.x), (v1.y % v2.y), (v1.z % v2.z), (v1.w % v2.w) };
}

static inline void operator+= (DirectX::XMUINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x += *itr;
    itr++;
    v1.y += *itr;
    itr++;
    v1.z += *itr;
    itr++;
    v1.w += *itr;
}

static inline void operator-= (DirectX::XMUINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x -= *itr;
    itr++;
    v1.y -= *itr;
    itr++;
    v1.z -= *itr;
    itr++;
    v1.w -= *itr;
}

static inline void operator/= (DirectX::XMUINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x /= *itr;
    itr++;
    v1.y /= *itr;
    itr++;
    v1.z /= *itr;
    itr++;
    v1.w /= *itr;
}

static inline void operator*= (DirectX::XMUINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x *= *itr;
    itr++;
    v1.y *= *itr;
    itr++;
    v1.z *= *itr;
    itr++;
    v1.w *= *itr;
}

static inline void operator%= (DirectX::XMUINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x %= *itr;
    itr++;
    v1.y %= *itr;
    itr++;
    v1.z %= *itr;
    itr++;
    v1.w %= *itr;
}

_NODISCARD static inline auto operator+ (const DirectX::XMUINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    DirectX::XMUINT4 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x += *itr;
    itr++;
    temp.y += *itr;
    itr++;
    temp.z += *itr;
    itr++;
    temp.w += *itr;

    return temp;
}

_NODISCARD static inline auto operator- (const DirectX::XMUINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    DirectX::XMUINT4 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x -= *itr;
    itr++;
    temp.y -= *itr;
    itr++;
    temp.z -= *itr;
    itr++;
    temp.w -= *itr;

    return temp;
}

_NODISCARD static inline auto operator* (const DirectX::XMUINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    DirectX::XMUINT4 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x *= *itr;
    itr++;
    temp.y *= *itr;
    itr++;
    temp.z *= *itr;
    itr++;
    temp.w *= *itr;

    return temp;
}

_NODISCARD static inline auto operator/ (const DirectX::XMUINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    DirectX::XMUINT4 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x /= *itr;
    itr++;
    temp.y /= *itr;
    itr++;
    temp.z /= *itr;
    itr++;
    temp.w /= *itr;

    return temp;
}

_NODISCARD static inline auto operator% (const DirectX::XMUINT4& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 4u && "不正なイニシャライザーリスト");

    DirectX::XMUINT4 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x %= *itr;
    itr++;
    temp.y %= *itr;
    itr++;
    temp.z %= *itr;
    itr++;
    temp.w %= *itr;

    return temp;
}

static inline void operator+= (DirectX::XMUINT4& v1, const int num)
{
    v1.x += num;
    v1.y += num;
    v1.z += num;
    v1.w += num;
}

static inline void operator-= (DirectX::XMUINT4& v1, const int num)
{
    v1.x -= num;
    v1.y -= num;
    v1.z -= num;
    v1.w -= num;
}

static inline void operator/= (DirectX::XMUINT4& v1, const int num)
{
    v1.x /= num;
    v1.y /= num;
    v1.z /= num;
    v1.w /= num;
}

static inline void operator*= (DirectX::XMUINT4& v1, const int num)
{
    v1.x *= num;
    v1.y *= num;
    v1.z *= num;
    v1.w *= num;
}

static inline void operator%= (DirectX::XMUINT4& v1, const int num)
{
    v1.x %= num;
    v1.y %= num;
    v1.z %= num;
    v1.w %= num;
}

_NODISCARD static inline constexpr auto operator+ (const DirectX::XMUINT4& v1, const int num)
{
    return DirectX::XMUINT4{ v1.x + num, v1.y + num, v1.z + num, v1.w + num };
}

_NODISCARD static inline constexpr auto operator- (const DirectX::XMUINT4& v1, const int num)
{
    return DirectX::XMUINT4{ v1.x - num, v1.y - num, v1.z - num, v1.w - num };
}

_NODISCARD static inline constexpr auto operator* (const DirectX::XMUINT4& v1, const int num)
{
    return DirectX::XMUINT4{ v1.x * num, v1.y * num, v1.z * num, v1.w * num };
}

_NODISCARD static inline constexpr auto operator/ (const DirectX::XMUINT4& v1, const int num)
{
    return DirectX::XMUINT4{ v1.x / num, v1.y / num, v1.z / num, v1.w / num };
}

_NODISCARD static inline constexpr auto operator% (const DirectX::XMUINT4& v1, const int num)
{
    return DirectX::XMUINT4{ (v1.x % num), (v1.y % num), (v1.z % num), (v1.w % num) };
}

_NODISCARD static inline constexpr bool operator== (const DirectX::XMUINT4& v1, const DirectX::XMUINT4& v2)
{
    return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w);
}

_NODISCARD static inline constexpr bool operator!= (const DirectX::XMUINT4& v1, const DirectX::XMUINT4& v2)
{
    return !((v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z) && (v1.w == v2.w));
}

//-------------------------------------------------------------------------------------------------------------
//. XMUINT3系
//-------------------------------------------------------------------------------------------------------------

static inline void operator+= (DirectX::XMUINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x += *itr;
    itr++;
    v1.y += *itr;
    itr++;
    v1.z += *itr;
}

static inline void operator-= (DirectX::XMUINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x -= *itr;
    itr++;
    v1.y -= *itr;
    itr++;
    v1.z -= *itr;
}

static inline void operator/= (DirectX::XMUINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x /= *itr;
    itr++;
    v1.y /= *itr;
    itr++;
    v1.z /= *itr;
}

static inline void operator*= (DirectX::XMUINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x *= *itr;
    itr++;
    v1.y *= *itr;
    itr++;
    v1.z *= *itr;
}

static inline void operator%= (DirectX::XMUINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x *= *itr;
    itr++;
    v1.y *= *itr;
    itr++;
    v1.z *= *itr;
}

_NODISCARD static inline auto operator+ (const DirectX::XMUINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    DirectX::XMUINT3 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x += *itr;
    itr++;
    temp.y += *itr;
    itr++;
    temp.z += *itr;

    return temp;
}

_NODISCARD static inline auto operator- (const DirectX::XMUINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    DirectX::XMUINT3 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x -= *itr;
    itr++;
    temp.y -= *itr;
    itr++;
    temp.z -= *itr;

    return temp;
}

_NODISCARD static inline auto operator* (const DirectX::XMUINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    DirectX::XMUINT3 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x *= *itr;
    itr++;
    temp.y *= *itr;
    itr++;
    temp.z *= *itr;

    return temp;
}

_NODISCARD static inline auto operator/ (const DirectX::XMUINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    DirectX::XMUINT3 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x /= *itr;
    itr++;
    temp.y /= *itr;
    itr++;
    temp.z /= *itr;

    return temp;
}

_NODISCARD static inline auto operator% (const DirectX::XMUINT3& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 3u && "不正なイニシャライザーリスト");

    DirectX::XMUINT3 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x *= *itr;
    itr++;
    temp.y *= *itr;
    itr++;
    temp.z *= *itr;

    return temp;
}

static inline void operator+= (DirectX::XMUINT3& v1, const DirectX::XMUINT3& v2)
{
    v1.x += v2.x;
    v1.y += v2.y;
    v1.z += v2.z;
}

static inline void operator-= (DirectX::XMUINT3& v1, const DirectX::XMUINT3& v2)
{
    v1.x -= v2.x;
    v1.y -= v2.y;
    v1.z -= v2.z;
}

static inline void operator*= (DirectX::XMUINT3& v1, const DirectX::XMUINT3& v2)
{
    v1.x *= v2.x;
    v1.y *= v2.y;
    v1.z *= v2.z;
}

static inline void operator/= (DirectX::XMUINT3& v1, const DirectX::XMUINT3& v2)
{
    v1.x /= v2.x;
    v1.y /= v2.y;
    v1.z /= v2.z;
}

static inline void operator%= (DirectX::XMUINT3& v1, const DirectX::XMUINT3& v2)
{
    v1.x %= v2.x;
    v1.y %= v2.y;
    v1.z %= v2.z;
}

_NODISCARD static inline constexpr auto operator+ (const DirectX::XMUINT3& v1, const DirectX::XMUINT3& v2)
{
    return DirectX::XMUINT3{ v1.x + v2.x, v1.y + v2.y, v1.z + v2.z };
}

_NODISCARD static inline constexpr auto operator- (const DirectX::XMUINT3& v1, const DirectX::XMUINT3& v2)
{
    return DirectX::XMUINT3{ v1.x - v2.x, v1.y - v2.y, v1.z - v2.z };
}

_NODISCARD static inline constexpr auto operator* (const DirectX::XMUINT3& v1, const DirectX::XMUINT3& v2)
{
    return DirectX::XMUINT3{ v1.x * v2.x, v1.y * v2.y, v1.z * v2.z };
}

_NODISCARD static inline constexpr auto operator/ (const DirectX::XMUINT3& v1, const DirectX::XMUINT3& v2)
{
    return DirectX::XMUINT3{ v1.x / v2.x, v1.y / v2.y, v1.z / v2.z };
}

_NODISCARD static inline constexpr auto operator% (const DirectX::XMUINT3& v1, const DirectX::XMUINT3& v2)
{
    return DirectX::XMUINT3{ (v1.x % v2.x), (v1.y % v2.y), (v1.z % v2.z) };
}

static inline void operator+= (DirectX::XMUINT3& v1, const int num)
{
    v1.x += num;
    v1.y += num;
    v1.z += num;
}

static inline void operator-= (DirectX::XMUINT3& v1, const int num)
{
    v1.x -= num;
    v1.y -= num;
    v1.z -= num;
}

static inline void operator/= (DirectX::XMUINT3& v1, const int num)
{
    v1.x /= num;
    v1.y /= num;
    v1.z /= num;
}

static inline void operator*= (DirectX::XMUINT3& v1, const int num)
{
    v1.x *= num;
    v1.y *= num;
    v1.z *= num;
}

static inline void operator%= (DirectX::XMUINT3& v1, const int num)
{
    v1.x %= num;
    v1.y %= num;
    v1.z %= num;
}

_NODISCARD static inline constexpr auto operator+ (const DirectX::XMUINT3& v1, const int num)
{
    return DirectX::XMUINT3{ v1.x + num, v1.y + num, v1.z + num };
}

_NODISCARD static inline constexpr auto operator- (const DirectX::XMUINT3& v1, const int num)
{
    return DirectX::XMUINT3{ v1.x - num, v1.y - num, v1.z - num };
}

_NODISCARD static inline constexpr auto operator* (const DirectX::XMUINT3& v1, const int num)
{
    return DirectX::XMUINT3{ v1.x * num, v1.y * num, v1.z * num };
}

_NODISCARD static inline constexpr auto operator% (const DirectX::XMUINT3& v1, const int num)
{
    return DirectX::XMUINT3{ (v1.x % num), (v1.y % num), (v1.z % num) };
}

_NODISCARD static inline constexpr auto operator/ (const DirectX::XMUINT3& v1, const int num)
{
    return DirectX::XMUINT3{ v1.x / num, v1.y / num, v1.z / num };
}

_NODISCARD static inline constexpr bool operator== (const DirectX::XMUINT3& v1, const DirectX::XMUINT3& v2)
{
    return ((v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z));
}

_NODISCARD static inline constexpr bool operator!= (const DirectX::XMUINT3& v1, const DirectX::XMUINT3& v2)
{
    return !((v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z));
}

//-------------------------------------------------------------------------------------------------------------
//. XMUINT2系
//-------------------------------------------------------------------------------------------------------------

static inline void operator+= (DirectX::XMUINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x += *itr;
    itr++;
    v1.y += *itr;
}

static inline void operator-= (DirectX::XMUINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x -= *itr;
    itr++;
    v1.y -= *itr;
}

static inline void operator/= (DirectX::XMUINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x /= *itr;
    itr++;
    v1.y /= *itr;
}

static inline void operator*= (DirectX::XMUINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x *= *itr;
    itr++;
    v1.y *= *itr;
}

static inline void operator%= (DirectX::XMUINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    auto itr{ v2.begin() };
    v1.x %= *itr;
    itr++;
    v1.y %= *itr;
}

_NODISCARD static inline auto operator+ (const DirectX::XMUINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    DirectX::XMUINT2 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x += *itr;
    itr++;
    temp.y += *itr;

    return temp;
}

_NODISCARD static inline auto operator- (const DirectX::XMUINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    DirectX::XMUINT2 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x -= *itr;
    itr++;
    temp.y -= *itr;

    return temp;
}

_NODISCARD static inline auto operator* (const DirectX::XMUINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    DirectX::XMUINT2 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x *= *itr;
    itr++;
    temp.y *= *itr;

    return temp;
}

_NODISCARD static inline auto operator/ (const DirectX::XMUINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    DirectX::XMUINT2 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x /= *itr;
    itr++;
    temp.y /= *itr;

    return temp;
}

_NODISCARD static inline auto operator% (const DirectX::XMUINT2& v1, const std::initializer_list<int>& v2)
{
    assert(v2.size() == 2u && "不正なイニシャライザーリスト");

    DirectX::XMUINT2 temp{ v1 };
    auto itr{ v2.begin() };

    temp.x %= *itr;
    itr++;
    temp.y %= *itr;

    return temp;
}

static inline void operator+= (DirectX::XMUINT2& v1, const DirectX::XMUINT2& v2)
{
    v1.x += v2.x;
    v1.y += v2.y;
}

static inline void operator-= (DirectX::XMUINT2& v1, const DirectX::XMUINT2& v2)
{
    v1.x -= v2.x;
    v1.y -= v2.y;
}

static inline void operator/= (DirectX::XMUINT2& v1, const DirectX::XMUINT2& v2)
{
    v1.x /= v2.x;
    v1.y /= v2.y;
}

static inline void operator*= (DirectX::XMUINT2& v1, const DirectX::XMUINT2& v2)
{
    v1.x *= v2.x;
    v1.y *= v2.y;
}

static inline void operator%= (DirectX::XMUINT2& v1, const DirectX::XMUINT2& v2)
{
    v1.x %= v2.x;
    v1.y %= v2.y;
}

_NODISCARD static inline constexpr auto operator+ (const DirectX::XMUINT2& v1, const DirectX::XMUINT2& v2)
{
    return DirectX::XMUINT2{ v1.x + v2.x, v1.y + v2.y };
}

_NODISCARD static inline constexpr auto operator- (const DirectX::XMUINT2& v1, const DirectX::XMUINT2& v2)
{
    return DirectX::XMUINT2{ v1.x - v2.x, v1.y - v2.y };
}

_NODISCARD static inline constexpr auto operator* (const DirectX::XMUINT2& v1, const DirectX::XMUINT2& v2)
{
    return DirectX::XMUINT2{ v1.x * v2.x, v1.y * v2.y };
}

_NODISCARD static inline constexpr auto operator/ (const DirectX::XMUINT2& v1, const DirectX::XMUINT2& v2)
{
    return DirectX::XMUINT2{ v1.x / v2.x, v1.y / v2.y };
}

_NODISCARD static inline constexpr auto operator% (const DirectX::XMUINT2& v1, const DirectX::XMUINT2& v2)
{
    return DirectX::XMUINT2{ (v1.x % v2.x), (v1.y % v2.y) };
}

static inline void operator+= (DirectX::XMUINT2& v1, const int num)
{
    v1.x += num;
    v1.y += num;
}

static inline void operator-= (DirectX::XMUINT2& v1, const int num)
{
    v1.x -= num;
    v1.y -= num;
}

static inline void operator/= (DirectX::XMUINT2& v1, const int num)
{
    v1.x /= num;
    v1.y /= num;
}

static inline void operator*= (DirectX::XMUINT2& v1, const int num)
{
    v1.x *= num;
    v1.y *= num;
}

static inline void operator%= (DirectX::XMUINT2& v1, const int num)
{
    v1.x %= num;
    v1.y %= num;
}

_NODISCARD static inline constexpr auto operator+ (const DirectX::XMUINT2& v1, const int num)
{
    return DirectX::XMUINT2{ v1.x + num, v1.y + num };
}

_NODISCARD static inline constexpr auto operator- (const DirectX::XMUINT2& v1, const int num)
{
    return DirectX::XMUINT2{ v1.x - num, v1.y - num };
}

_NODISCARD static inline constexpr auto operator* (const DirectX::XMUINT2& v1, const int num)
{
    return DirectX::XMUINT2{ v1.x * num, v1.y * num };
}

_NODISCARD static inline constexpr auto operator/ (const DirectX::XMUINT2& v1, const int num)
{
    return DirectX::XMUINT2{ v1.x / num, v1.y / num };
}

_NODISCARD static inline constexpr auto operator% (const DirectX::XMUINT2& v1, const int num)
{
    return DirectX::XMUINT2{ (v1.x % num), (v1.y % num) };
}

_NODISCARD static inline constexpr bool operator== (const DirectX::XMUINT2& v1, const DirectX::XMUINT2& v2)
{
    return ((v1.x == v2.x) && (v1.y == v2.y));
}

_NODISCARD static inline constexpr bool operator!= (const DirectX::XMUINT2& v1, const DirectX::XMUINT2& v2)
{
    return !((v1.x == v2.x) && (v1.y == v2.y));
}

//-------------------------------------------------------------------------------------------------------------
// 特殊変換関数
//-------------------------------------------------------------------------------------------------------------

inline namespace XmuintHelper
{
    // 型上げ-----------------------------------------------------------------------------------------------

    _NODISCARD static inline auto RaiseToXMUINT4(const DirectX::XMUINT3& vec, const uint32_t w_component = 0u)
    {
        return DirectX::XMUINT4{ vec.x, vec.y, vec.z, w_component };
    }

    _NODISCARD static inline auto RaiseToXMUINT4(const DirectX::XMUINT2& vec, const uint32_t z_component = 0u, const uint32_t w_component = 0u)
    {
        return DirectX::XMUINT4{ vec.x, vec.y, z_component, w_component };
    }

    _NODISCARD static inline auto RaiseToXMUINT3(const DirectX::XMUINT2& vec, const uint32_t z_component = 0u)
    {
        return DirectX::XMUINT3{ vec.x, vec.y, z_component };
    }

    // 型下げ-----------------------------------------------------------------------------------------------

    // W, Z成分が切り捨てられる
    _NODISCARD static inline auto LowerToXMUINT2(const DirectX::XMUINT4& vec)
    {
        return DirectX::XMUINT2{ vec.x, vec.y };
    }

    // Z成分が切り捨てられる
    _NODISCARD static inline auto LowerToXMUINT2(const DirectX::XMUINT3& vec)
    {
        return DirectX::XMUINT2{ vec.x, vec.y };
    }

    // W成分が切り捨てられる
    _NODISCARD static inline auto LowerToXMUINT3(const DirectX::XMUINT4& vec)
    {
        return DirectX::XMUINT3{ vec.x, vec.y, vec.z };
    }
}

最後に

 相変わらずコードが長いですが、皆さんが不要だと思うコードは削除・変更して使ってください。

HnniTns
ゲームAIに興味がある専門学校生のゲームプログラマー。 主にC・C++でプログラムをしています(少しだけPython)。 ゆるく気ままにメモを兼ねて投稿していきます。 人間メモしないと忘れますし(笑) RecastNavigationをもっと広めたい!!
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away