1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2025-02-17 11:45:50 +00:00

Add assignment operators.

This commit is contained in:
King_DuckZ 2016-02-19 21:56:10 +01:00
parent 64b5affa4f
commit 7da13f6677
2 changed files with 45 additions and 0 deletions

View file

@ -66,6 +66,13 @@ namespace mchlib {
DirIterator ( VecIterator parBegin, VecIterator parEnd, const PathName* parBasePath, std::size_t parLevelOffset );
~DirIterator ( void ) noexcept;
DirIterator& operator= ( DirIterator&& parOther );
DirIterator& operator= ( const DirIterator& parOther );
template <bool OtherConst>
DirIterator& operator= ( typename std::enable_if<std::is_convertible<typename DirIterator<OtherConst>::VecIterator, VecIterator>::value, DirIterator<OtherConst>>::type&& parOther );
template <bool OtherConst>
DirIterator& operator= ( const typename std::enable_if<std::is_convertible<typename DirIterator<OtherConst>::VecIterator, VecIterator>::value, DirIterator<OtherConst>>::type& parOther );
private:
void increment ( void );
difference_type distance_to ( const DirIterator<Const>& parOther ) const;

View file

@ -99,6 +99,44 @@ namespace mchlib {
DirIterator<Const>::~DirIterator() noexcept {
}
template <bool Const>
DirIterator<Const>& DirIterator<Const>::operator= (DirIterator&& parOther) {
m_current = std::move(parOther.m_current);
m_end = std::move(parOther.m_end);
m_base_path = std::move(parOther.m_base_path);
m_level_offset = parOther.m_level_offset;
return *this;
}
template <bool Const>
DirIterator<Const>& DirIterator<Const>::operator= (const DirIterator& parOther) {
m_current = parOther.m_current;
m_end = parOther.m_end;
m_base_path = parOther.m_base_path;
m_level_offset = parOther.m_level_offset;
return *this;
}
template <bool Const>
template <bool OtherConst>
DirIterator<Const>& DirIterator<Const>::operator= (typename std::enable_if<std::is_convertible<typename DirIterator<OtherConst>::VecIterator, VecIterator>::value, DirIterator<OtherConst>>::type&& parOther) {
m_current = parOther.m_current;
m_end = parOther.m_end;
m_base_path = std::move(parOther.m_base_path);
m_level_offset = parOther.m_level_offset;
return *this;
}
template <bool Const>
template <bool OtherConst>
DirIterator<Const>& DirIterator<Const>::operator= (const typename std::enable_if<std::is_convertible<typename DirIterator<OtherConst>::VecIterator, VecIterator>::value, DirIterator<OtherConst>>::type& parOther) {
m_current = parOther.m_current;
m_end = parOther.m_end;
m_base_path = parOther.m_base_path;
m_level_offset = parOther.m_level_offset;
return *this;
}
template <bool Const>
void DirIterator<Const>::increment() {
assert(PathName(m_current->abs_path).pop_right() == *m_base_path);