$include_dir="/home/hyper-archives/boost-users/include";
include("$include_dir/msg-header.inc")
?>
- Next message: Aaron Levy: "Re: [Boost-users] [assign][ptr_container] Exception safety of ptr_list_of, ptr_push_back, ptr_map_insert, etc."
- Previous message: Aaron Levy: "[Boost-users] [assign][ptr_container] Exception safety of ptr_list_of, ptr_push_back, ptr_map_insert, etc."
- In reply to: Aaron Levy: "[Boost-users] [assign][ptr_container] Exception safety of ptr_list_of, ptr_push_back, ptr_map_insert, etc."
- Next in thread: Aaron Levy: "Re: [Boost-users] [assign][ptr_container] Exception safety of ptr_list_of, ptr_push_back, ptr_map_insert, etc."
- Reply: Aaron Levy: "Re: [Boost-users] [assign][ptr_container] Exception safety of ptr_list_of, ptr_push_back, ptr_map_insert, etc."
On 24-09-2014 04:45, Aaron Levy wrote:
> I am trying to understand how ptr_list_of or ptr_push_back provide more exception safety.
>
> I can write something like:
>
> boost::ptr_vector<Foo> vec;
> push_back(vec)(new Foo)(new Foo);
>
> Is the order of evaluation of the two "new Foo" expressions indeterminate here? If not, then if the second new throws, the destructor of vec should be invoked. The Foo object allocated by the first new and now part of vec should also get released as part of that.
That would not be safe.
The intention is that you can forward to the constructor such that the
new expression happens inside the library:
push_back( vec )()();
See
http://www.boost.org/doc/libs/1_56_0_b1/libs/assign/doc/index.html#ptr_push_back
kind regards
-Thorsten
- Next message: Aaron Levy: "Re: [Boost-users] [assign][ptr_container] Exception safety of ptr_list_of, ptr_push_back, ptr_map_insert, etc."
- Previous message: Aaron Levy: "[Boost-users] [assign][ptr_container] Exception safety of ptr_list_of, ptr_push_back, ptr_map_insert, etc."
- In reply to: Aaron Levy: "[Boost-users] [assign][ptr_container] Exception safety of ptr_list_of, ptr_push_back, ptr_map_insert, etc."
- Next in thread: Aaron Levy: "Re: [Boost-users] [assign][ptr_container] Exception safety of ptr_list_of, ptr_push_back, ptr_map_insert, etc."
- Reply: Aaron Levy: "Re: [Boost-users] [assign][ptr_container] Exception safety of ptr_list_of, ptr_push_back, ptr_map_insert, etc."
$include_dir="/home/hyper-archives/boost-users/include";
include("$include_dir/msg-footer.inc");
?>