diff --git a/include/boost/move/algorithm.hpp b/include/boost/move/algorithm.hpp index 5a0c25f..36a46be 100644 --- a/include/boost/move/algorithm.hpp +++ b/include/boost/move/algorithm.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include //copy, copy_backward #include //uninitialized_copy @@ -110,10 +111,22 @@ F uninitialized_move(I f, I l, F r ) { typedef typename std::iterator_traits::value_type input_value_type; - while (f != l) { - ::new(static_cast(&*r)) input_value_type(boost::move(*f)); - ++f; ++r; + + F back = r; + BOOST_TRY{ + while (f != l) { + void * const addr = static_cast(::boost::move_detail::addressof(*r)); + ::new(addr) input_value_type(::boost::move(*f)); + ++f; ++r; + } } + BOOST_CATCH(...){ + for (; back != r; ++back){ + back->~input_value_type(); + } + BOOST_RETHROW; + } + BOOST_CATCH_END return r; }