|
Boost Users : |
Subject: Re: [Boost-users] [interprocess] access dynamically accessed shared region in another process
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2009-04-01 15:13:33
> Meanwhile I suspected as much, but didn't know for sure how to interpret the
> docs.
> Also, this alignment check taken from the docs doesn't compile anymore with a
> pointer type as such:
>
> struct transfer_buffer {
> boost::interprocess::offset_ptr<void> buf;
> size_t bufsize;
> };
> ...
> ret->bufsize = SIZE;
> ret->buf = seg->allocate_aligned(ret->bufsize, Alignment);
>
> // Check alignment
> assert((static_cast<void *>(ret->buf) - static_cast<void *>(0)) % Alignment ==
> 0);
Obviously, offset_ptr is not a pointer so it can be static_cast'ed.
offset_ptr is a smart pointer that emulates a pointer that can be placed
in shared memory. See offset_ptr docs and implementation for more
details. Try
// Check alignment
assert((static_cast<void *>(ret->buf.get()) - static_cast<void *>(0)) %
Alignment ==
> 0);
Regards,
Ion
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net