Adapting Interface-Incomplete Types at Compile Time
By Matthew Wilson, December 01, 2005
When an adapter template makes demands that a potential underlying type cannot fulfill, Interred Interface Adaptation can expand the number of adaptable types.
December, 2005: Adapting Interface-Incomplete Types At Compile Time
Listing 2
template <typename C>
class sequence_range
{
public:
typedef typename C::reference reference;
typedef typename C::const_reference const_reference;
typedef typename C::iterator iterator;
public:
sequence_range(C &c)
: m_current(c.begin())
, m_end(c.end())
{}
public:
reference current()
{
return *m_current;
}
const_reference current() const
{
return *m_current;
}
bool is_open() const
{
return m_current != m_end;
}
void advance()
{
++m_current;
}
private:
iterator m_current;
iterator m_end;
};