Support non-const to const conversions.
This commit is contained in:
parent
2be3823442
commit
05b34b4818
3 changed files with 35 additions and 1 deletions
|
@ -39,6 +39,7 @@ enum class IconDisplayFlag {
|
||||||
|
|
||||||
template <bool Const>
|
template <bool Const>
|
||||||
class BasicBlock {
|
class BasicBlock {
|
||||||
|
friend class BasicBlock<true>;
|
||||||
public:
|
public:
|
||||||
using data_type = typename std::conditional<Const, const uint8_t, uint8_t>::type;
|
using data_type = typename std::conditional<Const, const uint8_t, uint8_t>::type;
|
||||||
typedef FrameIterator<Const, Const> iterator;
|
typedef FrameIterator<Const, Const> iterator;
|
||||||
|
@ -49,6 +50,8 @@ public:
|
||||||
|
|
||||||
BasicBlock (data_type* blk, std::size_t index);
|
BasicBlock (data_type* blk, std::size_t index);
|
||||||
BasicBlock (data_type* blk, BasicFrame<Const> toc_entry, std::size_t index);
|
BasicBlock (data_type* blk, BasicFrame<Const> toc_entry, std::size_t index);
|
||||||
|
template <bool Const2> BasicBlock (const BasicBlock<Const2>& other);
|
||||||
|
BasicBlock(BasicBlock&&) = default;
|
||||||
~BasicBlock();
|
~BasicBlock();
|
||||||
|
|
||||||
iterator begin();
|
iterator begin();
|
||||||
|
@ -107,6 +110,14 @@ inline int32_t calc_icon_count (IconDisplayFlag idf) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <bool Const>
|
||||||
|
template <bool Const2>
|
||||||
|
inline BasicBlock<Const>::BasicBlock (const BasicBlock<Const2>& other) {
|
||||||
|
m_index = other.m_index;
|
||||||
|
m_toc_entry = other.m_toc_entry;
|
||||||
|
m_begin = other.m_begin;
|
||||||
|
}
|
||||||
|
|
||||||
using Block = BasicBlock<false>;
|
using Block = BasicBlock<false>;
|
||||||
using ConstBlock = BasicBlock<true>;
|
using ConstBlock = BasicBlock<true>;
|
||||||
} //namespace mc::psx
|
} //namespace mc::psx
|
||||||
|
|
|
@ -25,13 +25,16 @@
|
||||||
namespace mc::psx {
|
namespace mc::psx {
|
||||||
template <bool Const>
|
template <bool Const>
|
||||||
class BasicFrame {
|
class BasicFrame {
|
||||||
|
friend class BasicFrame<true>;
|
||||||
using data_type = typename std::conditional<Const, const uint8_t, uint8_t>::type;
|
using data_type = typename std::conditional<Const, const uint8_t, uint8_t>::type;
|
||||||
public:
|
public:
|
||||||
static const constexpr unsigned int Size = 128;
|
static const constexpr unsigned int Size = 128;
|
||||||
|
|
||||||
|
BasicFrame() = default;
|
||||||
BasicFrame (data_type* data, std::size_t index);
|
BasicFrame (data_type* data, std::size_t index);
|
||||||
BasicFrame (const BasicFrame&) = default;
|
BasicFrame (const BasicFrame<Const>&) = default;
|
||||||
BasicFrame (BasicFrame&&) = default;
|
BasicFrame (BasicFrame&&) = default;
|
||||||
|
template <bool Const2> BasicFrame (const BasicFrame<Const2>& other);
|
||||||
|
|
||||||
data_type* begin() { return m_data; }
|
data_type* begin() { return m_data; }
|
||||||
data_type* end() { return m_data + size(); }
|
data_type* end() { return m_data + size(); }
|
||||||
|
@ -39,8 +42,12 @@ public:
|
||||||
const data_type* cend() const { return m_data + size(); }
|
const data_type* cend() const { return m_data + size(); }
|
||||||
const data_type* begin() const { return m_data; }
|
const data_type* begin() const { return m_data; }
|
||||||
const data_type* end() const { return m_data + size(); }
|
const data_type* end() const { return m_data + size(); }
|
||||||
|
|
||||||
data_type& operator[] (std::size_t index);
|
data_type& operator[] (std::size_t index);
|
||||||
const data_type& operator[] (std::size_t index) const;
|
const data_type& operator[] (std::size_t index) const;
|
||||||
|
BasicFrame<Const>& operator= (BasicFrame<Const>&&) = default;
|
||||||
|
BasicFrame<Const>& operator= (const BasicFrame<Const>&) = default;
|
||||||
|
template <bool Const2> BasicFrame<Const>& operator= (const BasicFrame<Const2>& other);
|
||||||
|
|
||||||
static constexpr std::size_t size() { return Size; }
|
static constexpr std::size_t size() { return Size; }
|
||||||
|
|
||||||
|
@ -68,6 +75,13 @@ inline T read_as (const BasicFrame<Const>& frame, std::size_t offset) {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <bool Const>
|
||||||
|
template <bool Const2>
|
||||||
|
inline BasicFrame<Const>::BasicFrame (const BasicFrame<Const2>& other) {
|
||||||
|
m_index = other.m_index;
|
||||||
|
m_data = other.m_data;
|
||||||
|
}
|
||||||
|
|
||||||
using Frame = BasicFrame<false>;
|
using Frame = BasicFrame<false>;
|
||||||
using ConstFrame = BasicFrame<true>;
|
using ConstFrame = BasicFrame<true>;
|
||||||
} //namespace mc::psx
|
} //namespace mc::psx
|
||||||
|
|
|
@ -38,6 +38,15 @@ auto BasicFrame<Const>::operator[] (std::size_t index) const -> const data_type&
|
||||||
return m_data[index];
|
return m_data[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <bool Const>
|
||||||
|
template <bool Const2>
|
||||||
|
BasicFrame<Const>& BasicFrame<Const>::operator= (const BasicFrame<Const2>& other) {
|
||||||
|
m_index = other.m_index;
|
||||||
|
m_data = other.m_data;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template class BasicFrame<true>;
|
template class BasicFrame<true>;
|
||||||
template class BasicFrame<false>;
|
template class BasicFrame<false>;
|
||||||
|
template BasicFrame<true>& BasicFrame<true>::operator=(const BasicFrame<false>&);
|
||||||
} //namespace mc::psx
|
} //namespace mc::psx
|
||||||
|
|
Loading…
Add table
Reference in a new issue