RE: [libxml++] node iterators
- From: andy glew amd com
- To: libxmlplusplus-general lists sourceforge net
- Subject: RE: [libxml++] node iterators
- Date: Tue, 27 May 2003 15:49:24 -0700
> One problem I faced is the type return by iterator::operator*().
> I first wanted to return a Node &. It is, I think, more
> logical, and avoid
> writing things like (*iter)->do_something().
> However this change the use of dynamic_cast to 'test' the
> type of node. If the
> cast fail we have an exception instead of just returning a
> null pointer.
>
> So the question is :
> What do you expect as a return type for
> Node::ChildrenList::iterator::operator*() ?
I always use Node& for such code. (In more detail,
I use a T& if the value is copied into the container,
and if modifying the value in the container does not
affect the value copied from; I use T* if modifying
the value
To get a non-trapping dynamic cast, the user can always
take the address:
dynamic_cast<Special_Node*>(&(*iter))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]