segmented_array question

E

Ebenezer

Shalom

My marshalling deques adventure has been stymied by the C++
standards morass.... Now I'm focusing on segmented_arrays.
Would the author of segmented_array comment on adding the
following to the segmented_array file?

template <typename T, std::size_t N = 64, typename A =
std::allocator<T> >
class segmented_iterator : public ::neolib::segmented_array<T, N,
A>::iterator
{
typedef typename ::neolib::segmented_array<T, N, A>::iterator
base;
public:
segmented_iterator(base const& x) : base(x) {}
typename base::segment_type& segment() { return base::seg(); }
};


That's a slightly modified version of something from the
segmented_array web pages. Tia.


Brian Wood
Ebenezer Enterprises
http://webEbenezer.net
 
E

Ebenezer

Hi,

I don't think it would be within the spirit of the standard C++
container library to formally provide a mechanism to access the internal
data structures of a container; the provided public interface should be
as similar to what the standard C++ library provides.

What this means to me is having to:

1. maintain my own copy of segmented_array.h and update it
when a new version of the code is adopted or

2. put the code in a separate file and include it when
needed including code generation contexts.

I hope you will reconsider. It could be under an ifdef if
that would help.
I prefer to keep
accessing segmented_array's segments an esoteric feature. :)

Accessing vector's segment is an esoteric feature?

If others want to comment on this, please do.


Brian Wood
http://wnd.com
 
E

Ebenezer

Feel free to do this; my license permits it.

Thanks, I've already concluded that was fine and am including
copies of several of your files in my archive.
Sounds like a better idea.

Agreed, but not as good as what I suggested at first.
Sorry but no; exposing the internal data structures of a container is
Doing It Wrong Thing (tm) as it:

1) Allows the user to break the container class invariant.
2) Is not in the spirit of the STL.
3) Is not "clean".





Yes; the segmented_array container is designed like any STL container in
that it provides a public interface to access the controlled sequence in
a standard way.  Accessing the segments is not accessing the controlled
sequence in a standard way just as trying to access the chunks of a
std::deque's controlled sequence isn't.

I don't think there's a problem with being able to access a
vector's segment. If you do that you take responsibility
upon yourself for making sure everything is kosher.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top