segmented_array question

Discussion in 'C++' started by Ebenezer, Sep 29, 2011.

  1. Ebenezer

    Ebenezer Guest

    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, Sep 29, 2011
    #1
    1. Advertising

  2. Ebenezer

    Ebenezer Guest

    On Sep 29, 8:07 am, Leigh Johnston <> 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, Sep 30, 2011
    #2
    1. Advertising

  3. Ebenezer

    Ebenezer Guest

    On Sep 29, 8:25 pm, Leigh Johnston <> wrote:
    > On 30/09/2011 01:43, Ebenezer wrote:
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > > On Sep 29, 8:07 am, Leigh Johnston<>  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.
    Ebenezer, Sep 30, 2011
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sean
    Replies:
    1
    Views:
    578
    Cowboy \(Gregory A. Beamer\)
    Oct 20, 2003
  2. =?Utf-8?B?UnlhbiBTbWl0aA==?=

    Quick Question - Newby Question

    =?Utf-8?B?UnlhbiBTbWl0aA==?=, Feb 14, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    640
    Iain Norman
    Feb 16, 2005
  3. =?Utf-8?B?YW5kcmV3MDA3?=

    question row filter (more of sql query question)

    =?Utf-8?B?YW5kcmV3MDA3?=, Oct 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    933
    Scott Allen
    Oct 6, 2005
  4. Philip Meyer
    Replies:
    0
    Views:
    407
    Philip Meyer
    Nov 30, 2003
  5. Ebenezer

    Marshalling segmented_array

    Ebenezer, Feb 4, 2012, in forum: C++
    Replies:
    2
    Views:
    264
    Ebenezer
    Feb 7, 2012
Loading...

Share This Page