Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   segmented_array question (http://www.velocityreviews.com/forums/t754535-segmented_array-question.html)

Ebenezer 09-29-2011 01:35 AM

segmented_array question
 
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

Ebenezer 09-30-2011 12:43 AM

Re: segmented_array question
 
On Sep 29, 8:07*am, Leigh Johnston <le...@i42.co.uk> wrote:
> On 29/09/2011 02:35, Ebenezer wrote:
>
>
>
>
>
>
>
>
>
> > 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.

>
> 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


Ebenezer 09-30-2011 02:28 AM

Re: segmented_array question
 
On Sep 29, 8:25*pm, Leigh Johnston <le...@i42.co.uk> wrote:
> On 30/09/2011 01:43, Ebenezer wrote:
>
>
>
>
>
>
>
>
>
> > On Sep 29, 8:07 am, Leigh Johnston<le...@i42.co.uk> *wrote:
> >> On 29/09/2011 02:35, Ebenezer wrote:

>
> >>> 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.

>
> >> 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

>
> 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.

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

>
> Sounds like a better idea.


Agreed, but not as good as what I suggested at first.

>
>
>
> > I hope you will reconsider. *It could be under an ifdef if
> > that would help.

>
> 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".
>
>
>
> >> I prefer to keep
> >> accessing segmented_array's segments an esoteric feature. :)

>
> > Accessing vector's segment is an esoteric feature?

>
> 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.




All times are GMT. The time now is 05:41 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57