I'm interested in something like this, but I am not sure if your
implementation meets the needs I often seem to have.

1. I very often am given a raw buffer by pointer and wish to acquire it into
a more RAII-like container without copying.
2. Also I would like to provide a customer deleter.

Obviously these criteria in themselves are met well by any smart pointer
that has a customer deleter, but then you lose iterators, array syntax,
push/ pop etc. It would be nice to have the best of both worlds.
scoped_array and shared_array go some way towards this, but not all the way.

I don't know whether, again, this would all be better implemented as
policies of a generic smart pointer framework (or even managed_resource or
whatever the name might be).

Regards,

[)o
IhIL...

----- Original Message -----
From: "Kevin Atkinson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, March 04, 2003 11:05 AM
Subject: [boost] Any Interest In a Raw Memory Buffer


>
> Is there any interest in a vector like container which is designed to make
> working with raw memory easy.  It is different from a vector<char> (with
> the additional assumption that the objects are stored in memory
> sequentially) is the following ways:
>
>   The integrator is defined to be a pointer to make working with functions
>     that use raw memory easy.
>
>   It can use a specific range of user supplied memory for its storage.
>     When using user memory it will never attempt to allocate more memory.
>     capacity() == max_size().
>
>   Any function which takes a range:
>     (const_iterator start, const_iterator stop)
>   can also take a void pointer and a size ie:
>     (const void * data, size_type size)
>
>   Any function which takes an iterator to represent a position within
>     the exiting object can also take an offset.  If two iterators are
>     used to represent a range than an offset and a size can also be used.
>
>   Like vector, push_back(), and pop_back() or constant time operations if
>     storage is available.  However, unlike vector, pop_front() is a
>     constant time operation and push_front() can be made to be constant
>     time operations.
>
>   support for replacing one range with another while moving the minimal
>     amount of memory possible:
>     replace(iterator start, iterator_stop,
>             const_iterator rstart, const_iterator rstop)
>
>   A special member function
>     template <typename U> U * datap(size_type pos = 0)
>   which allows treating the memory as another type without an ugly
>   reinterpret_cast.  This statement is equivalent to
>     reinterpret_cast<U *>(...) + pos
>
> My implementation is not a template.  It uses new[] and delete[] for
memory
> allocation and the data type is "unsigned char".  Since the main goal for
> this class was working with raw memory and not an array of objects I
> decided not to make it a template.
>
> Some of the features of Buffer might be useful for a more general purpose
> vector, such as the replace method and the ability to use user memory.
>
> If people are really interested I will post my code.
>
> I wrote it to make working with Berkeley database and sending network
> messages as painless as possible.
>
> Let me know.
> ---
> http://kevin.atkinson.dhs.org
>
>
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to