From 314d866dc914e8b69974fa733866478478fcfb8f Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 6 Nov 2003 01:25:30 +0000 Subject: [PATCH] Use GCC aligned attribute to simplify type_with_alignment [SVN r20690] --- .../boost/type_traits/type_with_alignment.hpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/boost/type_traits/type_with_alignment.hpp b/include/boost/type_traits/type_with_alignment.hpp index 213839a..56889e9 100644 --- a/include/boost/type_traits/type_with_alignment.hpp +++ b/include/boost/type_traits/type_with_alignment.hpp @@ -141,6 +141,31 @@ class type_with_alignment typedef align_t type; }; +#if defined(__GNUC__) +namespace align { +struct __attribute__((__aligned__(2))) a2 {}; +struct __attribute__((__aligned__(4))) a4 {}; +struct __attribute__((__aligned__(8))) a8 {}; +struct __attribute__((__aligned__(16))) a16 {}; +struct __attribute__((__aligned__(32))) a32 {}; +} + +template<> class type_with_alignment<1> { public: typedef char type; }; +template<> class type_with_alignment<2> { public: typedef align::a2 type; }; +template<> class type_with_alignment<4> { public: typedef align::a4 type; }; +template<> class type_with_alignment<8> { public: typedef align::a8 type; }; +template<> class type_with_alignment<16> { public: typedef align::a16 type; }; +template<> class type_with_alignment<32> { public: typedef align::a32 type; }; + +namespace detail { +BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,::boost::align::a2,true) +BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,::boost::align::a4,true) +BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,::boost::align::a8,true) +BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,::boost::align::a16,true) +BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,::boost::align::a32,true) +} +#endif + #else //