Boost logo

Boost :

From: Andrei Tovtchigretchko (andrey_at_[hidden])
Date: 2000-01-18 22:18:12

Jim Argeropoulos wrote:

> I can see how it would be used, but it also looks like a maintance
> nightmare. When Box changes, you better make sure you are not relying on
> internal order/format/number of Box's members.

Sorry, I cannot figure out what you mean.
Do you see any reliance on internal order/format/number of Box's members in
expression like:
copy( memb_iter(vbox.begin(),&Box::width),
    vwidth.begin() ); ?

The only information about Box that is used here is the name of the class
member -
"width". This is designed like mem_fun_ref STL.

> You also have to be sure
> someone does not pass in (depth,width] by mistake or missunderstanding.
You can do that kind of mistake with any "normal" iterator/container, if you
are not using
some "debug" version of STL (like stlport):
vector<int> a(10), b(10), c(10);
- will compile.

There is a way to make memb_iterators for Box::depth and Box::width
types by supplying &Box::depth and &Box::width as non-type template
for the iterator object (this will also conserve space in memb_iterator):
template <class _Iterator,class _MemberType,class _MemberPtr,_MemberPtr
class memb_iterator
    _Iterator x;
But in that case, I don't find the way to create a helper function that
would not require to
explicitly specify the type of the member (float in our example). So, I
decided against it.


Boost list run by bdawes at, gregod at, cpdaniel at, john at