boost::interprocess::shared_memory_object
can be constructed with the default constructor, which creates an empty shared_memory_object
(i.e. one that has no shared memory owned by it). Depending on the situation, my code might construct a shared_memory_object
that is empty. This means that sometimes I would need to check if a given shared_memory_object
is empty.
While this seems like something that's really easy to do, nowhere in the documentation does describe how to test a shared_memory_object
for emptiness!
I've looked at the code, which suggests that shared_memory_object::get_name()
returns an empty C-string when there is no associated shared memory, but nowhere does it seem to guarantee that I will never get the empty C-string when shared memory is associated. Furthermore, shared_memory_object::get_size()
might return false even if there is associated shared memory, if the size cannot be obtained, so this method can't be reliably used either.
What is the proper way to test a shared_memory_object
for emptiness?