Boost logo

Boost :

Subject: Re: [boost] interest in a stateful pointer library?
From: Christof Donat (cd_at_[hidden])
Date: 2017-10-02 10:37:57


Hi,

Am 02.10.2017 10:46, schrieb Hans Dembinski via Boost:
> I wrote a variant of std::unique_ptr, called tagged_ptr, which allows
> safe read/write access to a customisable number of bits in the pointer
> variable. You can find the library on github:
>
> https://github.com/HDembinski/stateful_pointer

I don't have a current use, but I think, it might be very useful in
memory constraint environments.

> One needs little imagination to find good use for those bits. As a
> proof of principle, I wrote an STL compatible string class which has
> the size of const char*, but can store up to 7 ASCII characters (on a
> 64 bit system) without allocating any memory on the heap (aka small
> string optimisation).

I understand, that this is only an example, but...

I have not yet written a STL compatible string class, nor have I taken
my time to look at existing implementations. Therefore I might be
completely wrong. In my understanding, it would contain a size_t
together with the const char*, so it will always be 16 bytes on a 64 Bit
system and you can have up to 14 chars plus one null byte without heap
allocation.

Christof


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk