Skip to content

Commit

Permalink
Make ref m_array and m_index const
Browse files Browse the repository at this point in the history
They still aren't trivially copyable, but don't seem to actually need to be (and BitFieldArrayRef can't be, because it needs to replace assignment with changing the array).
  • Loading branch information
Pokechu22 committed Feb 19, 2021
1 parent 865ceec commit c915a69
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions Source/Core/Common/BitField.h
Expand Up @@ -321,8 +321,6 @@ class BitFieldArrayConstRef
friend class BitFieldArrayConstIterator<position, bits, size, T, S>;

public:
constexpr BitFieldArrayConstRef(BitFieldArrayConstRef&& other) = default;

constexpr T Value() const { return m_array->Value(m_index); };
constexpr operator T() const { return Value(); }

Expand All @@ -333,10 +331,8 @@ class BitFieldArrayConstRef
{
}

// TODO: making these const causes the type to no longer by trivially copyable in MSVC for some
// reason
const BitFieldArray<position, bits, size, T, S>* m_array;
size_t m_index;
const BitFieldArray<position, bits, size, T, S>* const m_array;
const size_t m_index;
};

template <std::size_t position, std::size_t bits, std::size_t size, typename T, typename S>
Expand All @@ -346,8 +342,6 @@ class BitFieldArrayRef
friend class BitFieldArrayIterator<position, bits, size, T, S>;

public:
constexpr BitFieldArrayRef(BitFieldArrayRef&& other) = default;

constexpr T Value() const { return m_array->Value(m_index); };
constexpr operator T() const { return Value(); }
T operator=(const BitFieldArrayRef<position, bits, size, T, S>& value) const
Expand All @@ -367,10 +361,8 @@ class BitFieldArrayRef
{
}

// TODO: making these const causes the type to no longer by trivially copyable in MSVC for some
// reason
BitFieldArray<position, bits, size, T, S>* m_array;
size_t m_index;
BitFieldArray<position, bits, size, T, S>* const m_array;
const size_t m_index;
};

// Satisfies LegacyOutputIterator / std::output_iterator.
Expand Down Expand Up @@ -402,6 +394,8 @@ class BitFieldArrayIterator
constexpr BitFieldArrayIterator() = default;
// Required by LegacyIterator
constexpr BitFieldArrayIterator(const BitFieldArrayIterator& other) = default;
// Required by LegacyIterator
BitFieldArrayIterator& operator=(const BitFieldArrayIterator& other) = default;

public:
BitFieldArrayIterator& operator++()
Expand Down Expand Up @@ -452,6 +446,8 @@ class BitFieldArrayConstIterator
constexpr BitFieldArrayConstIterator() = default;
// Required by LegacyIterator
constexpr BitFieldArrayConstIterator(const BitFieldArrayConstIterator& other) = default;
// Required by LegacyIterator
BitFieldArrayConstIterator& operator=(const BitFieldArrayConstIterator& other) = default;

public:
BitFieldArrayConstIterator& operator++()
Expand Down

0 comments on commit c915a69

Please sign in to comment.