From 9f70f6619f22e730a5fed08cd56e46e7f328e770 Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Sun, 5 Mar 2017 19:10:56 -0500 Subject: [PATCH] Do not rely on size of type_with_alignment --- include/boost/smart_ptr/allocate_shared_array.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/boost/smart_ptr/allocate_shared_array.hpp b/include/boost/smart_ptr/allocate_shared_array.hpp index 6257c55..5fe6cbd 100644 --- a/include/boost/smart_ptr/allocate_shared_array.hpp +++ b/include/boost/smart_ptr/allocate_shared_array.hpp @@ -367,12 +367,22 @@ sp_objects(std::size_t size) BOOST_NOEXCEPT template BOOST_CONSTEXPR inline -typename sp_enable::value, std::size_t>::type -sp_align(std::size_t size) BOOST_NOEXCEPT +typename sp_enable::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 +BOOST_CONSTEXPR inline +typename sp_enable::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 BOOST_CONSTEXPR inline typename sp_enable::value, std::size_t>::type