The trick I am using with "this_translation_unit" works fine on GNU
and Clang, however it fails to compile on Microsoft because the
variable has internal linkage. I'm sure we can do this another way
using something from the Boost preprocessor library. The preprocessor
macro __COUNTER__ is available on every compiler I know of.
P.S. This is my second idea posted to the Boost dev list. My first one
Except this is more dangerous than a real arena allocator, since it's
single-shot. If the collection tries to make more than one allocation,
this will return the same pointer each time, potentially corrupting the
This makes it incompatible with list-like containers, and possibly risky
even with std::vector, depending on how its resize operation is
implemented. Using static_vector instead is much safer.
On Thu, 9 Jan 2020 at 16:28, Gavin Lambert via Boost <[hidden email]>
> On 7/01/2020 21:11, Frederick Gotham wrote:
> > I propose a new allocator that uses global (i.e. static duration) memory.
> This looks somewhat like an "arena allocator". You'll find many
> existing examples using that keyword.
https://brave.com/google-gdpr-workaround/ "We value your privacy, click here!" Sod off! - degski
"Anyone who believes that exponential growth can go on forever in a finite
world is either a madman or an economist" - Kenneth E. Boulding
"Growth for the sake of growth is the ideology of the cancer cell" - Edward