[container] Issues with non-copyable mapped-types

Hi, I have been trying to use Boost.Container to make a map<copyable_but_not_moveable, moveable_but_not_copyable>. Unfortunately I have been unable to do this because the value_type of boost::container::map is std::pair, which does not support move semantics (in C++03). This causes problems for the moveable_but_not_copyable type. It means that, for example: myMap[copyable_but_not_moveable()]; does not compile. This behaviour is fully supported in C++11 mode, and I see no reason why a custom C++03 pair class would be unable to use the Boost.Move emulation to achieve the same effect. Regards, Evan Wallace

On Thu, Sep 15, 2011 at 12:21 AM, onlyone@senet.com.au <onlyone@senet.com.au
wrote:
Hi,
I have been trying to use Boost.Container to make a map<copyable_but_not_moveable, moveable_but_not_copyable>.
Unfortunately I have been unable to do this because the value_type of boost::container::map is std::pair, which does not support move semantics (in C++03). This causes problems for the moveable_but_not_copyable type. It means that, for example:
myMap[copyable_but_not_moveable()];
does not compile. This behaviour is fully supported in C++11 mode, and I see no reason why a custom C++03 pair class would be unable to use the Boost.Move emulation to achieve the same effect.
I assume Boost.Container does not provide its own C++03 move-emulation pair class, does it? In which case, probably the fastest way to get such a pair class into Boost.Container is to provide a patch with an implementation. And, yes, I agree that this is a desirable and useful addition. - Jeff

El 15/09/2011 21:12, Jeffrey Lee Hellrung, Jr. escribió:
On Thu, Sep 15, 2011 at 12:21 AM, onlyone@senet.com.au<onlyone@senet.com.au
wrote:
Hi,
I have been trying to use Boost.Container to make a map<copyable_but_not_moveable, moveable_but_not_copyable>.
Unfortunately I have been unable to do this because the value_type of boost::container::map is std::pair, which does not support move semantics (in C++03). This causes problems for the moveable_but_not_copyable type. It means that, for example:
myMap[copyable_but_not_moveable()];
does not compile. This behaviour is fully supported in C++11 mode, and I see no reason why a custom C++03 pair class would be unable to use the Boost.Move emulation to achieve the same effect.
I assume Boost.Container does not provide its own C++03 move-emulation pair class, does it? In which case, probably the fastest way to get such a pair class into Boost.Container is to provide a patch with an implementation. And, yes, I agree that this is a desirable and useful addition.
It has some internal pair class that is reinterpret_cast-ed (alarm!) to std::pair (map requires std::pair, there's no choice). I think it is not a fully drop-in replacement for std::pair (e.g., piecewise_construct) but I think it can be a good start. Best, Ion

El 15/09/2011 9:21, onlyone@senet.com.au escribió:
Hi,
I have been trying to use Boost.Container to make a map<copyable_but_not_moveable, moveable_but_not_copyable>.
Unfortunately I have been unable to do this because the value_type of boost::container::map is std::pair, which does not support move semantics (in C++03). This causes problems for the moveable_but_not_copyable type. It means that, for example:
myMap[copyable_but_not_moveable()];
does not compile. This behaviour is fully supported in C++11 mode, and I see no reason why a custom C++03 pair class would be unable to use the Boost.Move emulation to achieve the same effect.
Regards, Evan Wallace
Can you send me a full compilable example so I can find a solution ASAP? Thanks, Ion
participants (3)
-
Ion Gaztañaga
-
Jeffrey Lee Hellrung, Jr.
-
onlyone@senet.com.au