From: Reid Sweatman (reids_at_[hidden])
Date: 1999-08-16 12:46:43
> I think that this would be the pattern for all methods that
> return iterators:
> call the method on the underlying data structure, and delete
> and redispatch
> if non-existing. At least for containers with stable iterators.
> Sure would be nice if there were some way to say this once
> and for all, as opposed
> to having to replicate the code for it everywhere.
> Hmmm.... that tickled a neuron. Sure enough, Stroustrup's
> D&EofC++ says that
> his original C with Classes had call and return methods where
> such hooks could be
> applied, and on page 268 he talks about how such method
> combination can be
> acheived manually - unfortunately, requiring code replication.
> So, since the feature is *not* in C++, maybe the right thing
> to do is to have an external
> program write the code for me.
Well, PERL makes a hell of a C++ preprocessor <g>. However, you could also
get away without having to hook all access methods by treating them the way,
say, the vector template treats the [ ] operator; if there's a valid object
there, it accesses it, else, it inserts one. Except in your case, it would
*delete* the nulled one it found. I suspect, though that this wouldn't
fulfill the things you really want to do with this class.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk