Do not rely on size of type_with_alignment

This commit is contained in:
Glen Fernandes
2017-03-05 19:10:56 -05:00
parent 8c058dfeee
commit 9f70f6619f

View File

@ -367,12 +367,22 @@ sp_objects(std::size_t size) BOOST_NOEXCEPT
template<class T, class U>
BOOST_CONSTEXPR inline
typename sp_enable<sp_less_align<T, U>::value, std::size_t>::type
sp_align(std::size_t size) BOOST_NOEXCEPT
typename sp_enable<sp_less_align<T, U>::value &&
(sizeof(U) % 2 == 0), std::size_t>::type
sp_align(std::size_t size) BOOST_NOEXCEPT_OR_NOTHROW
{
return (sizeof(T) * size + sizeof(U) - 1) & ~(sizeof(U) - 1);
}
template<class T, class U>
BOOST_CONSTEXPR inline
typename sp_enable<sp_less_align<T, U>::value &&
(sizeof(U) % 2 != 0), std::size_t>::type
sp_align(std::size_t size) BOOST_NOEXCEPT_OR_NOTHROW
{
return (sizeof(T) * size + sizeof(U) - 1) / sizeof(U) * sizeof(U);
}
template<class T, class U>
BOOST_CONSTEXPR inline
typename sp_enable<!sp_less_align<T, U>::value, std::size_t>::type