07/06/01 00:18:45
きちんとやろうとすると長くなるので要点だけ。
struct honya : public std::iterator<std::bidirectional_iterator_tag, char>
{
honya(const node *n = NULL) : node_ptr_(n)
{
}
// あとoperator=()もあったほうが。
honya &operator++()
{
node_ptr_ = node_ptr_->next;
return *this;
}
honya &operator--()
{
node_ptr_ = node_ptr_->prev;
return *this;
}
// 同様にoperator--(int)とoperator++(int)も定義すること。
char &operator*()
{
return node_ptr_->c;
}
// const版もいるかも。
private:
node *node_ptr_;
};
boost::regex_search(honya(&first_node), honya(&last_node), ...