From 5ae6927668a6ceabb0deb1ac50a7a81faad2a400 Mon Sep 17 00:00:00 2001 From: Eric Friedman Date: Mon, 14 Jul 2003 23:04:31 +0000 Subject: [PATCH] Various fixes and MSVC6 workaround. [SVN r19120] --- include/boost/aligned_storage.hpp | 59 +++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/include/boost/aligned_storage.hpp b/include/boost/aligned_storage.hpp index cea029c..755389e 100644 --- a/include/boost/aligned_storage.hpp +++ b/include/boost/aligned_storage.hpp @@ -20,6 +20,7 @@ #include // for std::size_t #include "boost/config.hpp" +#include "boost/detail/workaround.hpp" #include "boost/type_traits/alignment_of.hpp" #include "boost/type_traits/type_with_alignment.hpp" @@ -27,14 +28,15 @@ #include "boost/mpl/identity.hpp" namespace boost { -namespace detail { + +namespace detail { namespace aligned_storage { BOOST_STATIC_CONSTANT( std::size_t - , alignment_of_max_align = alignment_of::value + , alignment_of_max_align = ::boost::alignment_of::value ); -} // namespace detail +}} // namespace detail::aligned_storage template < std::size_t size_ @@ -48,11 +50,11 @@ private: // representation { char buf[size_]; - BOOST_DEDUCED_TYPENAME mpl::apply_if_c< - alignment_ == std::size_t(-1) - , mpl::identity - , type_with_alignment - > align_; + typename mpl::apply_if_c< + alignment_ == std::size_t(-1) + , mpl::identity + , type_with_alignment + >::type align_; } data_; public: // constants @@ -65,26 +67,26 @@ public: // constants std::size_t , alignment = ( alignment_ == std::size_t(-1) - ? detail::alignment_of_max_align + ? ::boost::detail::aligned_storage::alignment_of_max_align : alignment_ ) ); -#if BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(2)) - -public: // _should_ be noncopyable, but GCC compiler emits error - - aligned_storage(const aligned_storage&); - aligned_storage& operator=(const aligned_storage&); - -#else// !BOOST_WORKAROUND(__GNUC__, ...) +#if !BOOST_WORKAROUND(__GNUC__, <= 2) private: // noncopyable aligned_storage(const aligned_storage&); aligned_storage& operator=(const aligned_storage&); -#endif// BOOST_WORKAROUND(__GNUC__, ...) +#else // gcc2.x + +public: // _should_ be noncopyable, but GCC compiler emits error + + aligned_storage(const aligned_storage&); + aligned_storage& operator=(const aligned_storage&); + +#endif // gcc2.x workaround public: // structors @@ -103,13 +105,34 @@ public: // accessors return &data_.buf[0]; } +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1200) + const void* address() const { return &data_.buf[0]; } +#else // MSVC6 + + const void* address() const; + +#endif // MSVC6 workaround + }; +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) + +// MSVC6 seems not to like inline functions with const void* returns, so we +// declare the following here: + +template +const void* aligned_storage::address() const +{ + return const_cast< aligned_storage* >(this)->address(); +} + +#endif // MSVC6 workaround + } // namespace boost #endif // BOOST_ALIGNED_STORAGE_HPP