
I find shared_memory_object constructor semantics to be
rather inconvenient for embedding it into another
class.
Consider the following
class A
{
public:
A(int type) : shm_(pass params to the shared_memory_object ctor)
{
}
private:
shared_memory_object shm_;
};
If my class A is such that a shared_memory_object needs to be called with
either create_only or open_only based on
the type passed to A's constructor, I can't do it easily.
i.e. some thing like
A(int type) : shm_(type == something ? create_only : open_only) {}
This won't work because create_only & open_only are different types & this
will call 2 different overloaded constructors,
hence the above code will not compile.
Alternatives here are
1) make A a templated class instead of having type as a ctor param.
i.e.
template <class T>
class A
{
public:
A() : shm_(T(), other params) {}
};
then use
A