Avoid -Wsign-conversion warning in checked_delete.hpp

This commit is contained in:
Peter Dimov 2023-06-25 13:46:53 +03:00
parent 66890c3f3d
commit 216999e552

View File

@ -30,16 +30,33 @@ namespace boost
template<class T> inline void checked_delete(T * x) BOOST_NOEXCEPT
{
// intentionally complex - simplification causes regressions
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
#if defined(__cpp_static_assert) && __cpp_static_assert >= 200410L
static_assert( sizeof(T) != 0, "Type must be complete" );
#else
typedef char type_must_be_complete[ sizeof(T) ];
(void) sizeof(type_must_be_complete);
#endif
delete x;
}
template<class T> inline void checked_array_delete(T * x) BOOST_NOEXCEPT
{
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
#if defined(__cpp_static_assert) && __cpp_static_assert >= 200410L
static_assert( sizeof(T) != 0, "Type must be complete" );
#else
typedef char type_must_be_complete[ sizeof(T) ];
(void) sizeof(type_must_be_complete);
#endif
delete [] x;
}