Boost logo

Boost Users :

Subject: Re: [Boost-users] [Fwd: Re: [interprocess] shared_memory_object design]
From: Christian Henning (chhenning_at_[hidden])
Date: 2009-08-29 11:19:43


Ion, thanks for your answer. I did actually try to explain the matter
from the RAII standpoint. I think my colleague now understands. As for
the constructor. Perhaps, you could add a helper function:

template< typename T >
void make_shared_memory_object( shared_memory_object& shmem
                              , std::string& name
                              , std::size_t size
                              )
{
    shared_memory_object tmp( T(), name.c_str(), size );
    tmp.swap( shmem );
}

Regards,
Christian

2009/8/27 Ion Gaztañaga <igaztanaga_at_[hidden]>:
>
> Christian Henning escribió:
>>
>> Hi there, a colleague of mine is questioning the design decisions in
>> the shared_memory_object class. The assignment operator and copy
>> constructor are private. Why?
>
> Because the class own a unique resource just like a file. Is fstream
> copyable? No, movable (in c++0x) just like shared_memory_object. What should
> the copy constructor do?
>
>
> Also the constructor takes a type
>>
>> instead of a value as the first parameter. In his eyes it makes it
>> very inflexible since the creation of or attaching to shared_memory
>> area has to known at compile time.
>
> Ok, this is debatable, because with move semantics you can write:
>
> shared_memory_object obj(create?
>                        shared_memory_object(create_only, ...):
>                        shared_memory_object(open_only, ...));
>
> or
>
> shared_memory_object shm;
>
> if(create){
>   shared_memory_object tmp(create_only);
>   tmp.swap(shm);
> }
> else{
>   shared_memory_object tmp(open_only);
>   tmp.swap(shm);
> }
>
> Best,
>
> Ion
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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