|
Boost-Commit : |
From: john_at_[hidden]
Date: 2008-06-04 13:00:20
Author: johnmaddock
Date: 2008-06-04 13:00:19 EDT (Wed, 04 Jun 2008)
New Revision: 46127
URL: http://svn.boost.org/trac/boost/changeset/46127
Log:
Enable alignof intrinsic support.
Also fixes #1946.
Text files modified:
trunk/boost/type_traits/alignment_of.hpp | 11 +++++++++++
trunk/boost/type_traits/intrinsics.hpp | 3 +++
2 files changed, 14 insertions(+), 0 deletions(-)
Modified: trunk/boost/type_traits/alignment_of.hpp
==============================================================================
--- trunk/boost/type_traits/alignment_of.hpp (original)
+++ trunk/boost/type_traits/alignment_of.hpp 2008-06-04 13:00:19 EDT (Wed, 04 Jun 2008)
@@ -12,6 +12,7 @@
#include <boost/config.hpp>
#include <cstddef>
+#include <boost/type_traits/intrinsics.hpp>
// should be the last #include
#include <boost/type_traits/detail/size_t_trait_def.hpp>
@@ -55,11 +56,21 @@
template< typename T >
struct alignment_of_impl
{
+#ifndef BOOST_ALIGNMENT_OF
BOOST_STATIC_CONSTANT(std::size_t, value =
(::boost::detail::alignment_logic<
sizeof(::boost::detail::alignment_of_hack<T>) - sizeof(T),
sizeof(T)
>::value));
+#else
+ //
+ // We put this here, rather than in the definition of
+ // alignment_of below, because MSVC's __alignof doesn't
+ // always work in that context for some unexplained reason.
+ // (See type_with_alignment tests for test cases).
+ //
+ BOOST_STATIC_CONSTANT(std::size_t, value = BOOST_ALIGNMENT_OF(T));
+#endif
};
} // namespace detail
Modified: trunk/boost/type_traits/intrinsics.hpp
==============================================================================
--- trunk/boost/type_traits/intrinsics.hpp (original)
+++ trunk/boost/type_traits/intrinsics.hpp 2008-06-04 13:00:19 EDT (Wed, 04 Jun 2008)
@@ -42,6 +42,7 @@
// BOOST_IS_CONVERTIBLE(T,U) true if T is convertible to U
// BOOST_IS_ENUM(T) true is T is an enum
// BOOST_IS_POLYMORPHIC(T) true if T is a polymorphic type
+// BOOST_ALIGNMENT_OF(T) should evaluate to the alignment requirements of type T.
#ifdef BOOST_HAS_SGI_TYPE_TRAITS
// Hook into SGI's __type_traits class, this will pick up user supplied
@@ -104,6 +105,7 @@
# define BOOST_IS_ENUM(T) __is_enum(T)
// This one doesn't quite always do the right thing:
// # define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T)
+# define BOOST_ALIGNMENT_OF(T) __alignof(T)
# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
#endif
@@ -146,6 +148,7 @@
# define BOOST_IS_CLASS(T) __is_class(T)
# define BOOST_IS_ENUM(T) __is_enum(T)
# define BOOST_IS_POLYMORPHIC(T) __is_polymorphic(T)
+# define BOOST_ALIGNMENT_OF(T) __alignof__(T)
# define BOOST_HAS_TYPE_TRAITS_INTRINSICS
#endif
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk