|
Boost : |
From: Ion Gaztañaga (ion_g_m_at_[hidden])
Date: 2005-02-19 06:36:04
Hello Pavel,
>> T * ptr = shmem_segment.create<T>("ObjectName")[size]
>
> It could be then used:
>
> T* t = segment.create(...); // no smarteness used
> shmem_smart_pointer ptr = segment_create(...); // smart ptr used
> (void)segment.create(...); // no leak happens
The shared memory allocation is done in the proxy function, the example I've
put was just to see the const_ref-non_const-ref problem so
T* t = segment.create<T>("name"); -->
T* t = segment.create<T>("name")/*proxy object returned*/; -->
Is an invalid option and it does not compile, because that expresion returns
a temporary proxy object not assignable to T*. To build an object without
parameters, you should do:
T* t = segment.create<T>("name")( ); -->
T* t = segment.create<T>("name") /*proxy object returned, calling to
operator()*/
( /*empty param list*/); /*pointer
returned*/
because the argument-less operator() is the responsible for allocating _and_
constructing the object, so there are no leaks. Obviously, this syntax is
not very straight forward, and I should try to get more logical syntax when
default constructing objects:
T* t = segment.create<T>("name");
I will have a look at it, since I think this syntax is better, thank you for
the idea. Regarding to const/non_const parameter issue, I will try to make a
simpler example not involving proxies to just point out the problem and
repost the question hoping there is response.
Meanwhile, I keep on improving Shmem, currently adding boost unordered _map
as name/memory mapping association instead of assoc_vector to test
pros/cons.
Regards,
/Ion>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk