#include
using namespace std;
template
class ddeque {
public:
class iterator {
public:
typedef std::random_access_iterator_tag iterator_category;
};
};
template
class dlist {
public:
class iterator {
public:
typedef std::bidirectional_iterator_tag iterator_category;
};
};
template
struct diterator_traits {
typedef typename IterT::iterator::iterator_category iterator_category;
};
template
void doAdvance(IterT& iter, DistT d, std::random_access_iterator_tag)
{
//iter += d;
cout<<“random access”<
template
void doAdvance(IterT& iter, DistT d, std::bidirectional_iterator_tag)
{
/*
if (d>=0) {
while(d–) ++iter;
}
else {
while(d++) --iter;
}
*/
cout<<“bidirectional_iterator_tag”<
template
void doAdvance(IterT& iter, DistT d, std::input_iterator_tag)
{
if(d<0) {
throw std::out_of_range(“Negative distance”);
}
while (d–) ++iter;
}
template
void dadvance(IterT& iter, DistT d)
{
doAdvance(iter, d, typename diterator_traits::iterator_category());
}
int main() {
ddeque d;
dadvance
dlist c;
dadvance, int>(c,5);
return 0;
}