|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TCG_ANY_ITERATOR_H
|
|
Toshihiro Shimizu |
890ddd |
#define TCG_ANY_ITERATOR_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "base.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
\file any_iterator.h
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
\brief This file contains the implementation of a type-erased iterator template class.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
\details Type erasure is a C++ idiom about allocating an interface
|
|
Toshihiro Shimizu |
890ddd |
to an object who is then hidden as the interface's implementation detail.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
The cost of using a type-erased object instead of its actual type is typically
|
|
Toshihiro Shimizu |
890ddd |
measured in a heap access at construction and destruction, and one virtual
|
|
Toshihiro Shimizu |
890ddd |
function call per method invocation.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
A type-erased iterator can be useful to hide implementation details about container
|
|
Toshihiro Shimizu |
890ddd |
choices, yet providing an iterator-like interface to access the stored data.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TCG_RVALUES_SUPPORT
|
|
Toshihiro Shimizu |
890ddd |
#include <boost config.hpp=""></boost>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef BOOST_NO_RVALUE_REFERENCES
|
|
Toshihiro Shimizu |
890ddd |
#define TCG_RVALUES_SUPPORT 0
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define TCG_RVALUES_SUPPORT 1
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace tcg
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// any_iterator_concept (ie the interface)
|
|
Toshihiro Shimizu |
890ddd |
//****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename dist="" typename="" val,="" valptr,="" valref,=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
class any_iterator_concept
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
virtual ~any_iterator_concept() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual any_iterator_concept *clone() const = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual ValRef operator*() const = 0;
|
|
Toshihiro Shimizu |
890ddd |
virtual ValPtr operator->() const = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual bool operator==(const any_iterator_concept &other) const = 0;
|
|
Toshihiro Shimizu |
890ddd |
virtual bool operator!=(const any_iterator_concept &other) const = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual void operator++() = 0;
|
|
Toshihiro Shimizu |
890ddd |
virtual any_iterator_concept *operator++(int)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual void operator--() { assert(false); }
|
|
Toshihiro Shimizu |
890ddd |
virtual any_iterator_concept *operator--(int)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual bool operator<(const any_iterator_concept &) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
virtual bool operator>(const any_iterator_concept &) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
virtual bool operator<=(const any_iterator_concept &) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
virtual bool operator>=(const any_iterator_concept &) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual any_iterator_concept *operator+(Dist) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
virtual void operator+=(Dist d) { assert(false); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual any_iterator_concept *operator-(Dist) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
virtual void operator-=(Dist d) { assert(false); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual Dist operator-(const any_iterator_concept &) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual ValRef operator[](Dist) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
assert(false);
|
|
Toshihiro Shimizu |
890ddd |
return *(Val *)0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// any_iterator_model (ie the concrete interface implementations)
|
|
Toshihiro Shimizu |
890ddd |
//****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template
|
|
Toshihiro Shimizu |
890ddd |
typename Val, typename ValRef, typename ValPtr, typename Dist>
|
|
Toshihiro Shimizu |
890ddd |
class any_iterator_model
|
|
Toshihiro Shimizu |
890ddd |
: public any_iterator_concept<val, dist="" valptr,="" valref,=""></val,>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
typedef any_iterator_concept<val, dist="" valptr,="" valref,=""> any_it_concept;</val,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
any_iterator_model() : m_it() {}
|
|
Toshihiro Shimizu |
890ddd |
any_iterator_model(const It &it) : m_it(it) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
any_it_concept *clone() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return new any_iterator_model<it, dist="" iterator_cat,="" val,="" valptr,="" valref,="">(*this);</it,>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ValRef operator*() const { return m_it.operator*(); }
|
|
Toshihiro Shimizu |
890ddd |
ValPtr operator->() const { return m_it.operator->(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool operator==(const any_it_concept &other) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_it == static_cast<const &="" any_iterator_model="">(other).m_it;</const>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
bool operator!=(const any_it_concept &other) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_it != static_cast<const &="" any_iterator_model="">(other).m_it;</const>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void operator++() { ++m_it; }
|
|
Toshihiro Shimizu |
890ddd |
any_it_concept *operator++(int)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return new any_iterator_model<it, dist="" iterator_cat,="" val,="" valptr,="" valref,="">(m_it++);</it,>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
It m_it;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template
|
|
Toshihiro Shimizu |
890ddd |
typename Val, typename ValRef, typename ValPtr, typename Dist>
|
|
Toshihiro Shimizu |
890ddd |
class any_iterator_model<it, dist="" std::bidirectional_iterator_tag,="" val,="" valptr,="" valref,=""></it,>
|
|
Toshihiro Shimizu |
890ddd |
: public any_iterator_model<it, dist="" std::forward_iterator_tag,="" val,="" valptr,="" valref,=""></it,>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
typedef any_iterator_concept<val, dist="" valptr,="" valref,=""> any_it_concept;</val,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using any_iterator_model<it, dist="" std::forward_iterator_tag,="" val,="" valptr,="" valref,="">::m_it;</it,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
any_iterator_model() {}
|
|
Toshihiro Shimizu |
890ddd |
any_iterator_model(const It &it)
|
|
Toshihiro Shimizu |
890ddd |
: any_iterator_model<it, dist="" std::forward_iterator_tag,="" val,="" valptr,="" valref,="">(it) {}</it,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
any_it_concept *clone() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return new any_iterator_model<it, dist="" std::bidirectional_iterator_tag,="" val,="" valptr,="" valref,="">(*this);</it,>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void operator--() { --m_it; }
|
|
Toshihiro Shimizu |
890ddd |
any_it_concept *operator--(int)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return new any_iterator_model<it, dist="" std::bidirectional_iterator_tag,="" val,="" valptr,="" valref,="">(m_it--);</it,>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename dist="" it,="" typename="" val,="" valptr,="" valref,=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
class any_iterator_model<it, dist="" std::random_access_iterator_tag,="" val,="" valptr,="" valref,=""></it,>
|
|
Toshihiro Shimizu |
890ddd |
: public any_iterator_model<it, dist="" std::bidirectional_iterator_tag,="" val,="" valptr,="" valref,=""></it,>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
typedef any_iterator_concept<val, dist="" valptr,="" valref,=""> any_it_concept;</val,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using any_iterator_model<it, dist="" std::forward_iterator_tag,="" val,="" valptr,="" valref,="">::m_it;</it,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
any_iterator_model() {}
|
|
Toshihiro Shimizu |
890ddd |
any_iterator_model(const It &it)
|
|
Toshihiro Shimizu |
890ddd |
: any_iterator_model<it, dist="" std::bidirectional_iterator_tag,="" val,="" valptr,="" valref,="">(it) {}</it,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
any_it_concept *clone() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return new any_iterator_model<it, dist="" std::random_access_iterator_tag,="" val,="" valptr,="" valref,="">(*this);</it,>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool operator<(const any_it_concept &other) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_it < static_cast<const &="" any_iterator_model="">(other).m_it;</const>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
bool operator>(const any_it_concept &other) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_it > static_cast<const &="" any_iterator_model="">(other).m_it;</const>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
bool operator<=(const any_it_concept &other) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_it <= static_cast<const &="" any_iterator_model="">(other).m_it;</const>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
bool operator>=(const any_it_concept &other) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_it >= static_cast<const &="" any_iterator_model="">(other).m_it;</const>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
any_it_concept *operator+(Dist d) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return new any_iterator_model<it, dist="" std::random_access_iterator_tag,="" val,="" valptr,="" valref,="">(m_it + d);</it,>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void operator+=(Dist d) { m_it += d; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
any_it_concept *operator-(Dist d) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return new any_iterator_model<it, dist="" std::random_access_iterator_tag,="" val,="" valptr,="" valref,="">(m_it - d);</it,>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
void operator-=(Dist d) { m_it -= d; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Dist operator-(const any_it_concept &other) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_it - static_cast<const &="" any_iterator_model="">(other).m_it;</const>
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ValRef operator[](Dist d) const { return m_it[d]; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// any_iterator (ie the wrapper to the interface)
|
|
Toshihiro Shimizu |
890ddd |
//****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template
|
|
Toshihiro Shimizu |
890ddd |
typename ValRef = Val &, typename ValPtr = Val *, typename Dist = std::ptrdiff_t>
|
|
Toshihiro Shimizu |
890ddd |
class any_iterator
|
|
Toshihiro Shimizu |
890ddd |
: public std::iterator<iterator_cat, dist,="" val,="" valptr,="" valref=""></iterator_cat,>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
any_iterator_concept<val, dist="" valptr,="" valref,=""> *m_model;</val,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
any_iterator() : m_model(0) {}
|
|
Toshihiro Shimizu |
890ddd |
any_iterator(any_iterator_concept<val, dist="" valptr,="" valref,=""> *model) : m_model(model) {}</val,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename it=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
any_iterator(const It &it)
|
|
Toshihiro Shimizu |
890ddd |
: m_model(new any_iterator_model<it, dist="" iterator_cat,="" val,="" valptr,="" valref,="">(it)) {}</it,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
any_iterator(const any_iterator &other) : m_model(other.m_model->clone()) {}
|
|
Toshihiro Shimizu |
890ddd |
any_iterator &operator=(any_iterator other)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
swap(*this, other);
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~any_iterator() { delete m_model; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
friend void swap(any_iterator &a, any_iterator &b) { std::swap(a.m_model, b.m_model); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ValRef operator*() const { return m_model->operator*(); }
|
|
Toshihiro Shimizu |
890ddd |
ValPtr operator->() const { return m_model->operator->(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool operator==(const any_iterator &other) const { return m_model->operator==(*other.m_model); }
|
|
Toshihiro Shimizu |
890ddd |
bool operator!=(const any_iterator &other) const { return m_model->operator!=(*other.m_model); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
any_iterator &operator++()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
++*m_model;
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
any_iterator operator++(int) { return any_iterator((*m_model)++); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
any_iterator &operator--()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
--*m_model;
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
any_iterator operator--(int) { return any_iterator((*m_model)--); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool operator<(const any_iterator &other) const { return m_model->operator<(*other.m_model); }
|
|
Toshihiro Shimizu |
890ddd |
bool operator>(const any_iterator &other) const { return m_model->operator>(*other.m_model); }
|
|
Toshihiro Shimizu |
890ddd |
bool operator<=(const any_iterator &other) const { return m_model->operator<=(*other.m_model); }
|
|
Toshihiro Shimizu |
890ddd |
bool operator>=(const any_iterator &other) const { return m_model->operator>=(*other.m_model); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
any_iterator operator+(Dist d) const { return any_iterator((*m_model) + d); }
|
|
Toshihiro Shimizu |
890ddd |
any_iterator &operator+=(Dist d)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
(*m_model) += d;
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
any_iterator operator-(Dist d) const { return any_iterator((*m_model) - d); }
|
|
Toshihiro Shimizu |
890ddd |
any_iterator &operator-=(Dist d)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
(*m_model) -= d;
|
|
Toshihiro Shimizu |
890ddd |
return *this;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Dist operator-(const any_iterator &other) const { return m_model->operator-(*other.m_model); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ValRef operator[](Dist d) const { return m_model->operator[](d); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if (TCG_RVALUES_SUPPORT > 0)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
any_iterator(any_iterator &&other) : m_model(other.m_model)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
other.m_model = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template
|
|
Toshihiro Shimizu |
890ddd |
typename ValRef, typename ValPtr, typename Dist>
|
|
Toshihiro Shimizu |
890ddd |
any_iterator<val, dist="" iterator_cat,="" valptr,="" valref,=""> operator+(</val,>
|
|
Toshihiro Shimizu |
890ddd |
Dist d, const any_iterator<val, dist="" iterator_cat,="" valptr,="" valref,=""> &it) { return it + d; }</val,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Additional typedefs to the actual types
|
|
Toshihiro Shimizu |
890ddd |
//****************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename val=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct any_iterator<val, tcg::empty_type=""> {</val,>
|
|
Toshihiro Shimizu |
890ddd |
typedef any_iterator<val, std::input_iterator_tag=""> input;</val,>
|
|
Toshihiro Shimizu |
890ddd |
typedef any_iterator<val, std::output_iterator_tag=""> output;</val,>
|
|
Toshihiro Shimizu |
890ddd |
typedef any_iterator<val, std::forward_iterator_tag=""> forward;</val,>
|
|
Toshihiro Shimizu |
890ddd |
typedef any_iterator<val, std::bidirectional_iterator_tag=""> bidirectional;</val,>
|
|
Toshihiro Shimizu |
890ddd |
typedef any_iterator<val, std::random_access_iterator_tag=""> random;</val,>
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename &,="" *,="" dist="std::ptrdiff_t" typename="" val,="" valptr="Val" valref="Val"></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct any_it {
|
|
Toshihiro Shimizu |
890ddd |
typedef any_iterator<val, dist="" std::input_iterator_tag,="" valptr,="" valref,=""> input;</val,>
|
|
Toshihiro Shimizu |
890ddd |
typedef any_iterator<val, dist="" std::output_iterator_tag,="" valptr,="" valref,=""> output;</val,>
|
|
Toshihiro Shimizu |
890ddd |
typedef any_iterator<val, dist="" std::forward_iterator_tag,="" valptr,="" valref,=""> forward;</val,>
|
|
Toshihiro Shimizu |
890ddd |
typedef any_iterator<val, dist="" std::bidirectional_iterator_tag,="" valptr,="" valref,=""> bidirectional;</val,>
|
|
Toshihiro Shimizu |
890ddd |
typedef any_iterator<val, dist="" std::random_access_iterator_tag,="" valptr,="" valref,=""> random;</val,>
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace tcg
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif // TCG_ANY_ITERATOR_H
|