From 74e3b91d8ff7dc08e3ce29d981608f04f5b29cea Mon Sep 17 00:00:00 2001 From: John Maddock Date: Mon, 25 Apr 2005 16:42:08 +0000 Subject: [PATCH] Make sure that aligned_storage<>::type really is a POD type. [SVN r28475] --- include/boost/aligned_storage.hpp | 36 ++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/include/boost/aligned_storage.hpp b/include/boost/aligned_storage.hpp index bd16739..9ab94a0 100644 --- a/include/boost/aligned_storage.hpp +++ b/include/boost/aligned_storage.hpp @@ -35,16 +35,15 @@ BOOST_STATIC_CONSTANT( , alignment_of_max_align = ::boost::alignment_of::value ); -}} // namespace detail::aligned_storage - +// +// To be TR1 conforming this must be a POD type: +// template < std::size_t size_ - , std::size_t alignment_ = std::size_t(-1) + , std::size_t alignment_ > -class aligned_storage +struct aligned_storage_imp { -private: // representation - union data_t { char buf[size_]; @@ -55,10 +54,23 @@ private: // representation , type_with_alignment >::type align_; } data_; +}; + +}} // namespace detail::aligned_storage + +template < + std::size_t size_ + , std::size_t alignment_ = std::size_t(-1) +> +class aligned_storage +{ +private: // representation + + detail::aligned_storage::aligned_storage_imp data_; public: // constants - typedef aligned_storage type; + typedef detail::aligned_storage::aligned_storage_imp type; BOOST_STATIC_CONSTANT( std::size_t @@ -106,14 +118,14 @@ public: // accessors void* address() { - return &data_.buf[0]; + return this; } #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1200) const void* address() const { - return &data_.buf[0]; + return this; } #else // MSVC6 @@ -138,8 +150,12 @@ const void* aligned_storage::address() const #endif // MSVC6 workaround #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +// +// Make sure that is_pod recognises aligned_storage<>::type +// as a POD (Note that aligned_storage<> itself is not a POD): +// template -struct is_pod > +struct is_pod > BOOST_TT_AUX_BOOL_C_BASE(true) { BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(true)