Unified new and old versions of aligned_storage.

[SVN r27145]
This commit is contained in:
John Maddock
2005-02-05 12:49:06 +00:00
parent 30693414d1
commit 17e53bc1be
2 changed files with 19 additions and 44 deletions

View File

@@ -19,10 +19,13 @@
#include "boost/detail/workaround.hpp"
#include "boost/type_traits/alignment_of.hpp"
#include "boost/type_traits/type_with_alignment.hpp"
#include "boost/type_traits/is_pod.hpp"
#include "boost/mpl/eval_if.hpp"
#include "boost/mpl/identity.hpp"
#include "boost/type_traits/detail/bool_trait_def.hpp"
namespace boost {
namespace detail { namespace aligned_storage {
@@ -55,6 +58,8 @@ private: // representation
public: // constants
typedef aligned_storage<size_, alignment_> type;
BOOST_STATIC_CONSTANT(
std::size_t
, size = size_
@@ -132,6 +137,18 @@ const void* aligned_storage<S,A>::address() const
#endif // MSVC6 workaround
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <std::size_t size_, std::size_t alignment_>
struct is_pod<boost::aligned_storage<size_,alignment_> >
BOOST_TT_AUX_BOOL_C_BASE(true)
{
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(true)
};
#endif
} // namespace boost
#include "boost/type_traits/detail/bool_trait_undef.hpp"
#endif // BOOST_ALIGNED_STORAGE_HPP

View File

@@ -7,48 +7,6 @@
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
#ifndef BOOST_TT_ALIGNED_STORAGE_HPP_INCLUDED
#define BOOST_TT_ALIGNED_STORAGE_HPP_INCLUDED
#include "boost/type_traits/type_with_alignment.hpp"
#include <boost/type_traits/is_pod.hpp>
// should be the last #include
#include "boost/type_traits/detail/bool_trait_def.hpp"
namespace boost {
namespace detail{
template <class T, std::size_t N>
struct storage
{
union
{
char m_buf[N];
T m_align;
};
};
}
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class T, std::size_t K>
struct is_pod<boost::detail::storage<T,K> >
BOOST_TT_AUX_BOOL_C_BASE(true)
{
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(true)
};
#endif
template <std::size_t Len, std::size_t Align>
struct aligned_storage
{
typedef typename type_with_alignment<Align>::type aligned_type;
typedef detail::storage<aligned_type,Len> type;
};
} // namespace boost
#include "boost/type_traits/detail/bool_trait_undef.hpp"
# define BOOST_TT_ALIGNED_STORAGE_HPP_INCLUDED
# include <boost/aligned_storage.hpp>
#endif // BOOST_TT_ALIGNED_STORAGE_HPP_INCLUDED