mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-02-19 12:04:54 +00:00
Enable interoperability between iterators
This commit is contained in:
parent
b34070f23c
commit
84a2617c24
2 changed files with 22 additions and 2 deletions
|
@ -33,9 +33,11 @@ namespace mchlib {
|
|||
class DirIterator : public boost::iterator_facade<DirIterator<Const>, FileRecordData, boost::forward_traversal_tag> {
|
||||
friend class mchlib::SetListingView;
|
||||
friend class boost::iterator_core_access;
|
||||
template <bool> friend class DirIterator;
|
||||
typedef boost::iterator_facade<DirIterator<Const>, FileRecordData, boost::random_access_traversal_tag> base_class;
|
||||
typedef typename base_class::difference_type difference_type;
|
||||
typedef typename base_class::reference reference;
|
||||
struct enabler {};
|
||||
public:
|
||||
typedef typename std::conditional<
|
||||
Const,
|
||||
|
@ -44,13 +46,17 @@ namespace mchlib {
|
|||
>::type VecIterator;
|
||||
|
||||
DirIterator ( DirIterator<Const>&& parOther );
|
||||
template <bool OtherConst>
|
||||
DirIterator ( DirIterator<OtherConst>&& parOther, typename std::enable_if<std::is_convertible<typename DirIterator<OtherConst>::VecIterator, VecIterator>::value, enabler>::type = enabler() );
|
||||
DirIterator ( VecIterator parBegin, VecIterator parEnd, std::unique_ptr<PathName>&& parBasePath );
|
||||
~DirIterator ( void ) noexcept;
|
||||
|
||||
private:
|
||||
void increment ( void );
|
||||
difference_type distance_to ( const DirIterator<Const>& parOther ) const;
|
||||
bool equal ( const DirIterator<Const>& parOther ) const;
|
||||
template <bool OtherConst>
|
||||
bool equal ( const DirIterator<OtherConst>& parOther ) const;
|
||||
|
||||
reference dereference ( void ) const;
|
||||
bool is_end ( void ) const;
|
||||
|
||||
|
|
|
@ -46,6 +46,10 @@ namespace mchlib {
|
|||
|
||||
namespace implem {
|
||||
template class DirIterator<true>;
|
||||
template class DirIterator<false>;
|
||||
template bool DirIterator<true>::equal ( const DirIterator<false>& ) const;
|
||||
template bool DirIterator<true>::equal ( const DirIterator<true>& ) const;
|
||||
template DirIterator<true>::DirIterator ( DirIterator<false>&&, enabler );
|
||||
|
||||
template <bool Const>
|
||||
DirIterator<Const>::DirIterator (DirIterator<Const>&& parOther) :
|
||||
|
@ -55,6 +59,15 @@ namespace mchlib {
|
|||
{
|
||||
}
|
||||
|
||||
template <bool Const>
|
||||
template <bool OtherConst>
|
||||
DirIterator<Const>::DirIterator (DirIterator<OtherConst>&& parOther, typename std::enable_if<std::is_convertible<typename DirIterator<OtherConst>::VecIterator, VecIterator>::value, enabler>::type) :
|
||||
m_current(parOther.m_current),
|
||||
m_end(parOther.m_end),
|
||||
m_base_path(std::move(parOther.m_base_path))
|
||||
{
|
||||
}
|
||||
|
||||
template <bool Const>
|
||||
DirIterator<Const>::DirIterator (VecIterator parBegin, VecIterator parEnd, std::unique_ptr<PathName>&& parBasePath) :
|
||||
m_current(parBegin),
|
||||
|
@ -98,7 +111,8 @@ namespace mchlib {
|
|||
}
|
||||
|
||||
template <bool Const>
|
||||
bool DirIterator<Const>::equal (const DirIterator<Const>& parOther) const {
|
||||
template <bool OtherConst>
|
||||
bool DirIterator<Const>::equal (const DirIterator<OtherConst>& parOther) const {
|
||||
return
|
||||
(m_end == parOther.m_end) and
|
||||
(
|
||||
|
|
Loading…
Add table
Reference in a new issue