Fixed Trac #12920 ("movelib::unique_ptr: incorrect pointer type for nested array")

This commit is contained in:
Ion Gaztañaga 2017-04-09 13:44:08 +02:00
parent 135e598bc4
commit 67bda76dad
4 changed files with 36 additions and 2 deletions

View File

@ -788,6 +788,13 @@ Many thanks to all boosters that have tested, reviewed and improved the library.
[section:release_notes Release Notes]
[section:release_notes_boost_1_64 Boost 1.64 Release]
* Fixed bug:
* [@https://svn.boost.org/trac/boost/ticket/12920 #12920 ['"movelib::unique_ptr: incorrect pointer type for nested array"]].
[endsect]
[section:release_notes_boost_1_62 Boost 1.62 Release]
* Documented new limitations reported in Trac tickets

View File

@ -96,6 +96,22 @@ typedef int bool_conversion::* explicit_bool_arg;
typedef int (bool_conversion::*nullptr_type)();
#endif
template<bool B>
struct is_array_del
{};
template<class T>
void call_delete(T *p, is_array_del<true>)
{
delete [] p;
}
template<class T>
void call_delete(T *p, is_array_del<false>)
{
delete p;
}
} //namespace move_upd {
// @endcond
@ -184,7 +200,7 @@ struct default_delete
//and T has no virtual destructor, then you have a problem
BOOST_STATIC_ASSERT(( !::boost::move_upmu::missing_virtual_destructor<default_delete, U>::value ));
element_type * const p = static_cast<element_type*>(ptr);
bmupmu::is_array<T>::value ? delete [] p : delete p;
move_upd::call_delete(p, move_upd::is_array_del<bmupmu::is_array<T>::value>());
}
//! <b>Effects</b>: Same as <tt>(*this)(static_cast<element_type*>(nullptr))</tt>.

View File

@ -397,7 +397,7 @@ struct pointer_type_imp
template <class T, class D>
struct pointer_type_imp<T, D, false>
{
typedef typename remove_extent<T>::type* type;
typedef T* type;
};
template <class T, class D>

View File

@ -75,6 +75,17 @@ void test()
typedef bml::unique_ptr<int[5], Deleter> P;
BOOST_STATIC_ASSERT((bmupmu::is_same<P::pointer, Deleter::pointer>::value));
}
//Unbounded array of bounded array unique_ptr
{
typedef int int_5_t [5];
typedef bml::unique_ptr<int_5_t[]> P;
BOOST_STATIC_ASSERT((bmupmu::is_same<P::pointer, int_5_t*>::value));
}
{
typedef int int_5_t [5];
typedef bml::unique_ptr<int_5_t[], Deleter> P;
BOOST_STATIC_ASSERT((bmupmu::is_same<P::pointer, Deleter::pointer>::value));
}
}
} //namespace unique_ptr_pointer_type {